comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]Today's topics: * Zipping without a file - 5 messages, 5 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d97c18b4cd4dd37b * test if the string is a blank data string - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/681d0b9bedeb1d23 * Downloading HTML files from Server.. - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/158381c850332645 * Problem reading from nio socketchannels into a bytebuffer - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d8b57d1c9857a5b2 * java.net.URI.equals() - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/13482983512ae419 * J2SE 5.0 SDK - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/34434161a91e61bb * Java Class Browser - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c482dc903089e7aa * Thread synchronization - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/172837b7b0667fd1 * Extracting text data from MS Word document - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/adadc7b9250f0fb1 * Arrays - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/af535098658bf258 * String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/39e65137dfea9036 * Inserting components into a JTextPane - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8de30a108c9b450 * simpleDateFormat and April month - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/383df9c88dcb10ba * Execute command on remote server - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aea2e27783906e46 ========================================================================== TOPIC: Zipping without a file http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d97c18b4cd4dd37b ========================================================================== == 1 of 5 == Date: Thurs, Sep 16 2004 8:14 am From: Andrew Thompson <[EMAIL PROTECTED]> On Thu, 16 Sep 2004 14:47:59 GMT, Tyler Reed wrote: > I'd like to compress a stream. However, the incoming data is not a file and, > more importantly, the outgoing data is not a file, it's just another > stream. Is the incoming data already compressed? AFAIU, the zip compression algorithm can only be applied to data once all the data is known, so if your incoming stream is uncompressed, you need to wait until you have a complete file before you can compress it and write to the output stream. HTH -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.lensescapes.com/ Images that escape the mundane == 2 of 5 == Date: Thurs, Sep 16 2004 8:29 am From: Rogan Dawes <[EMAIL PROTECTED]> Andrew Thompson wrote: > On Thu, 16 Sep 2004 14:47:59 GMT, Tyler Reed wrote: > > >>I'd like to compress a stream. However, the incoming data is not a file and, >>more importantly, the outgoing data is not a file, it's just another >>stream. > > > Is the incoming data already compressed? > > AFAIU, the zip compression algorithm can only > be applied to data once all the data is known, > so if your incoming stream is uncompressed, > you need to wait until you have a complete > file before you can compress it and write > to the output stream. > > HTH > Maybe the GZIPOutputStream is closer to what the OP was looking for? You can use that to compress a single file, and tools such as WinZip and other archivers will be able to uncompress it. If it has to be a ZIP archive for some reason, you could try writing your zip to a ByteArrayOutputStream, and then sending the contents of the BAOS to the user. This will involve buffering the entire compressed file in memory, which may or may not be acceptable. Regards, Rogan -- Rogan Dawes *ALL* messages to [EMAIL PROTECTED] will be dropped, and added to my blacklist. Please respond to "nntp AT dawes DOT za DOT net" == 3 of 5 == Date: Thurs, Sep 16 2004 8:45 am From: Stefan Schulz <[EMAIL PROTECTED]> Tyler Reed wrote: > I'd like to compress a stream. However, the incoming data is not a file and, > more importantly, the outgoing data is not a file, it's just another > stream. What can I use to compress the data? I've been playing around with > util.zip but it wants me to create a Zip Entry and I can't be injecting > irrelevant info like that into the data stream. Any ideas? java.util.zip.GZIPInputStream, and java.util.zip.GZIPOutputStream come to mind. For any further details, ask your friendly neighbourhood javadoc ;) == 4 of 5 == Date: Thurs, Sep 16 2004 8:55 am From: "Chris Uppal" <[EMAIL PROTECTED]> Tyler Reed wrote: > I'd like to compress a stream. Then java.util.zip.GZIPOutputStream is exactly the man for the job. Think of it as a "compressing decorator" (because that's what it is ;-) -- chris == 5 of 5 == Date: Thurs, Sep 16 2004 9:10 am From: Thomas Schodt <[EMAIL PROTECTED]> Tyler Reed wrote: > I'd like to compress a stream. However, the incoming data is not a file and, > more importantly, the outgoing data is not a file, it's just another > stream. What can I use to compress the data? I've been playing around with > util.zip but it wants me to create a Zip Entry and I can't be injecting > irrelevant info like that into the data stream. Any ideas? The first thing I thought of was STAC, but that seems to require a license. Google found me this site <http://datacompression.info/Lossless.shtml> ========================================================================== TOPIC: test if the string is a blank data string http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/681d0b9bedeb1d23 ========================================================================== == 1 of 1 == Date: Thurs, Sep 16 2004 8:26 am From: karlheinz klingbeil <[EMAIL PROTECTED]> Matt schrub am Donnerstag, 16. September 2004 01:39 folgendes: > If I just want to test if a string is blank data > string or not. Do you think this method is good > enough?? Or any better approach. Please advise. > Thanks. public boolean isBlankDataString(String s){ return (s==null) ? true : s.trim().equals(""); } -- greetz Karlheinz Klingbeil (lunqual) http://www.lunqual.de oder http:www.lunqual.net ========================================================================== TOPIC: Downloading HTML files from Server.. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/158381c850332645 ========================================================================== == 1 of 2 == Date: Thurs, Sep 16 2004 8:43 am From: [EMAIL PROTECTED] (Patrick) A website runs a Fantasy Football League for English soccer in the England They put up a list of the players and the points they have I am running a fantasy football for just a few friends I want to download the scores from this website Then parse them Then calculate the points for all the teams in our little Fantasy Football league Now to my problems... If I navigate to http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH And click on a link which calls the follow javascript function "javascript:dt_pop('PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167', 'remote', 610, 550, 10, 10, 'no', 'yes', 'no', 'no'); " A new page pops up, the browser say its url is http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167 Now with my code public class DownloadWebPage { public static void main (String[] args) throws IOException { URL url = new URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1"); BufferedReader webRead = new BufferedReader(new InputStreamReader(url.openStream())); String line; while ((line = webRead.readLine()) != null) { System.out.println(line); } } } I can download the page at http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH But I cannot download the page at http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167 That the javascript function "javascript:dt_pop('PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167', 'remote', 610, 550, 10, 10, 'no', 'yes', 'no', 'no'); " In the page http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH calls. When I try to download http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167 With my code, all i get is <HTML><HEAD><SCRIPT LANGUAGE="JAVASCRIPT">location.replace("http://www.dreamteamfc.com");</SCRIPT></HEAD></HTML> I noticed that when I access http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH The server sends a cookie. And then when I access http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167 I get the table of players and their respective points. But when I try to access http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167 without accessing http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH first, I just get redirected to http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH I used the following code public static void main (String[] args) throws IOException { URL url = new URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167"); URLConnection uc = url.openConnection(); System.out.println(uc.getHeaderField("Set-Cookie")); } To get the cookie, which was CF_HA=2415676698; Domain=.dreamteamfc.com; expires=Tue, 14-Sep-04 22:25:46 GMT; Path=/ I think CF_HA, is just a unique identifier, a variable which in incremented by the server for each new client Domain, is just the domain expires, is just the expiry date Path, hmm dunno Now I hardcoded the cookie into the code, with a valid expiry date public static void main (String[] args) throws IOException { URL url = new URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167"); URLConnection uc = url.openConnection(); String cookie = "CF_HA=2415676698; Domain=.dreamteamfc.com; expires=Tue, 14-Sep-04 22:25:46 GMT; Path=/"; uc.setRequestProperty("cookie",cookie); int i = 0; while ((i = uc.getInputStream().read()) != -1) { System.out.print((char) i); } } Now, when I run this code I get the following error Exception in thread "main" java.io.IOException: Server returned HTTP response code: 400 for URL: http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1133) at Test.main(Test.java:46) Am I sending the cookie correctly? Is there something else I must do? Any help/advice appreciated, regards pat == 2 of 2 == Date: Thurs, Sep 16 2004 9:26 am From: Paul Lutus <[EMAIL PROTECTED]> Patrick wrote: Do not multi-post. Choose one newsgroup, make one post. -- Paul Lutus http://www.arachnoid.com ========================================================================== TOPIC: Problem reading from nio socketchannels into a bytebuffer http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d8b57d1c9857a5b2 ========================================================================== == 1 of 1 == Date: Thurs, Sep 16 2004 8:48 am From: Paul Lutus <[EMAIL PROTECTED]> Jeff Silvis wrote: / ... [ about non-blocking I/O methods ] > In some of my code I have written a line more or less exactly like: > while (buffer.hasRemaining()) { > socketChannel.write (buffer); > } > > > and the code does just spin. What is an example of "something more > useful than this"? Obviously if you plan to use this kind of code, put it in a separate thread and use the blocking version of these I/O classes. What you in essence have done is use a non-blocking method and have arranged to block with it, in a particularly wasteful way. To put it another way, you never want to loop on a non-blocking method, because the method won't block for you. Your code is written to accommodate a conventional blocking I/O call. So please answer this question. Did you really want a blocking method and chose this one by mistake, or did you really want to learn how to use non-blocking methods, and chose this loop structure by mistake (even if from an "official " Web site)? -- Paul Lutus http://www.arachnoid.com ========================================================================== TOPIC: java.net.URI.equals() http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/13482983512ae419 ========================================================================== == 1 of 1 == Date: Thurs, Sep 16 2004 8:53 am From: Peter Davis <[EMAIL PROTECTED]> On 2004-09-16 03:00:29 -0700, Daniel Bonniot <[EMAIL PROTECTED]> said: > Peter Davis wrote: >> "When testing the user-information, path, query, fragment, >> authority, or scheme-specific parts of two URIs for equality, the raw >> forms rather than the encoded forms of these components are compared >> and the hexadecimal digits of escaped octets are compared without >> regard to case." >> >> First of all, is that a typo? I think it's trying to say "the raw >> forms rather than the /decoded/ forms...". > > Unless by raw they mean "decoded". But the implementation does not seem > to match that. The rest of the class is consistent with "raw" meaning the originally-parsed URI string, which will likely contain %XX escapes. Perhaps that's the whole problem. Some spec author at Sun probably meant raw==decoded, and some other implementor probably interpreted it as raw==encoded-but-not-normalized, like it is throughout the rest of the class. Otherwise it doesn't make any sense that two URIs can be semantically equal via character escapes but not equals(). > >> Aside from that, the problem is that it would make sense if two URIs >> with encoded or unencoded versions of the same characters should be >> equal, but they're not. I wrote a little test class: >> >> [...snip...] >> >> Outputs: >> >> foo%7Ebar == foo%7ebar => true >> foo%7Ebar == foo~bar => false >> foo%7ebar ==foo~bar => false >> >> Why in the world would it compare the raw rather than decoded forms of >> the URI? Anybody have any clues? > > Not a direct answer, but what should happen when non-ascii characters > occur, (directly or in encoded form)? For instance, is %E1 equal to á > (like it does in some latin-? encodings). It's specified that %XX escapes are decoded as if they are UTF-8 bytes, so %E1 wouldn't be equal to á but, for example, %E2%82%AC is equal to the Euro character. So anyway, I understand that the spec is the way it is, and it's perfectly unambiguous and reproducable in this manner, but it just seems useless to me. For example, if you have a URI like "foo/../bar", and you invoke normalize() on it, then that URI will be equal() to "bar". So there is a way to normalize paths, but there is no way to normalize escape sequences in a way that equals() will behave properly. This is a problem because %7E (~) is a notoriously confused character, with some applications escaping it and some not. -- Peter Davis <[EMAIL PROTECTED]> "Furthermore, I believe bacon prevents hair loss!" ========================================================================== TOPIC: J2SE 5.0 SDK http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/34434161a91e61bb ========================================================================== == 1 of 2 == Date: Thurs, Sep 16 2004 9:04 am From: Dino Buljubasic <[EMAIL PROTECTED]> I heard that there is 5.0 version but I can not find it on Sun's wweb page. All I found is J2SE 5.0 RC Can somebody send me a link? == 2 of 2 == Date: Thurs, Sep 16 2004 9:38 am From: kjc <[EMAIL PROTECTED]> You found it !! Dino Buljubasic wrote: > I heard that there is 5.0 version but I can not find it on Sun's wweb > page. All I found is J2SE 5.0 RC > > Can somebody send me a link? ========================================================================== TOPIC: Java Class Browser http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c482dc903089e7aa ========================================================================== == 1 of 2 == Date: Thurs, Sep 16 2004 9:22 am From: Albretch <[EMAIL PROTECTED]> I need a Java Class Browser and only found a number of dead links ._ http://joshua.haninge.kth.se/~bnar/aikd ._ http://www.pfu.co.jp/teikade/ ._ http://www.interchg.ubc.ca/steinbok/inspector and apparently dead end 'research' ones ._ http://www.sunlabs.com/research/forest/ COM.Sun.Labs.Forest.PJava.PJW2.2_slides_pdf.pdf and a few still live but abandoned or with not much going on: ._ http://www-ppg.dcs.st-and.ac.uk/Java/OCB/ I also went "class browser" site:mindprod.com and couldn't found much Do you know of any rich and reliable ones? == 2 of 2 == Date: Thurs, Sep 16 2004 9:40 am From: kjc <[EMAIL PROTECTED]> It there a problem with using Eclipse Albretch wrote: > > I need a Java Class Browser and only found a number of dead links > > ._ http://joshua.haninge.kth.se/~bnar/aikd > ._ http://www.pfu.co.jp/teikade/ > ._ http://www.interchg.ubc.ca/steinbok/inspector > > and apparently dead end 'research' ones > > ._ http://www.sunlabs.com/research/forest/ > COM.Sun.Labs.Forest.PJava.PJW2.2_slides_pdf.pdf > > and a few still live but abandoned or with not much going on: > > ._ http://www-ppg.dcs.st-and.ac.uk/Java/OCB/ > > I also went "class browser" site:mindprod.com > > and couldn't found much > > Do you know of any rich and reliable ones? > > > ========================================================================== TOPIC: Thread synchronization http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/172837b7b0667fd1 ========================================================================== == 1 of 1 == Date: Thurs, Sep 16 2004 9:25 am From: "xarax" <[EMAIL PROTECTED]> "Thomas G. Marshall" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] /snip/ > Override /all/ of the accessor/mutator's and methods with similar side > effects? Unless there is a protected/public common subroutine to all of > them, IMHO you've now created a technique that is adding more potential > instability than you were trying to avoid in the first place. Only the public methods would be overridden with synchronized variants. A better solution is to wrap the ArrayList within a new class that only has methods that are of interest to the client application. The wrapper instance is shared among the threads, instead of the raw ArrayList instance. > Interestingly (to me at least) there /are/ inner classes called, for one > example, Collections.SynchronizedCollection, etc. But it is declared with > package scope, so you cannot extend it. Hmmm, I can't find that class in the JavaDoc for 1.4.2. ========================================================================== TOPIC: Extracting text data from MS Word document http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/adadc7b9250f0fb1 ========================================================================== == 1 of 1 == Date: Thurs, Sep 16 2004 9:41 am From: Paul Lutus <[EMAIL PROTECTED]> Max wrote: > unfortunately this approach doesn't fit ... > > I cannot make users to save documents in some specific formats ... Then you cannot get RTF either, Ann's suggestion. Too bad. I guess you will have to see what MS Word converters are available on the receiving end. > The Big Idea is that > 1. user works with preferred document format (MS Word) > 2. sends it in a System > 3. System extracts text data from it and process it as necessary ... Yes, and for that, you will need an MS Word converter. Since the target platform is described as "UNIX", I can't go farther without finding out which unix. If it were Linux, I would know exactly what to tell you (a Linux installation can, and usually does, host several MS Word converter methods). -- Paul Lutus http://www.arachnoid.com ========================================================================== TOPIC: Arrays http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/af535098658bf258 ========================================================================== == 1 of 3 == Date: Thurs, Sep 16 2004 10:03 am From: [EMAIL PROTECTED] (Cassie) Arrays I am a student and am learning Java. I am not allowed to use graphical user interface, at this point. I MUST use an array to display 3 mortgages; 1.) 7 years, 5.35% interest, $200,000 principle 2.) 15 years, 5.5% interest, $200,000 principle 3.) 30 years at 5.75% interest, $200,000 principle I have accomplished this successfully BUT I also have to "list the loan balance and interest paid for each payment over the term of the loan". I am trying to call a payment and amortization method from 3 separate programs (7year.java, 15year.java & 30year.java). Is this possible? Do the programs need to be merged into one (this is possible)? If this is not possible what is while using the array? This is my program //importing classes import java.lang.Math; import java.text.NumberFormat; //identifying program public class Array2exp { //calling Currency formatting static NumberFormat nf = NumberFormat.getCurrencyInstance(); public static void main (String [] args) { // Array declration double mortgages []; double interest []; int term []; double amort []; double pay []; //Array creation mortgages = new double[3]; interest = new double [3]; term = new int [3]; amort = new double [3]; pay = new double [3] // Array initialization mortgages [0] = (200000*5.35*(Math.pow((1+5.35/1200),84)))/(1200*(Math.pow((1+5.35/1200),84)-1)); mortgages [1] = (200000*5.5*(Math.pow((1+5.5/1200),180)))/(1200*(Math.pow((1+5.5/1200),180)-1)); mortgages [2] = (200000*5.75*(Math.pow((1+5.75/1200),360)))/(1200*(Math.pow((1+5.75/1200),360)-1)); interest [0] = 5.35; interest [1] = 5.5; interest [2] = 5.75; term [0] = 7; term [1] = 15; term [2] = 30; amort [0] = 7year.amortization(); amort [1] = 15year.amortization(); amort [2] = 30year.amortization(); pay [0] = 7year.payment(); pay [1] = 15year.payment(); pay [2] = 30year.payment(); //for loop, (initialization, expression, update) for (int MonthlyPayment=0; MonthlyPayment<=2; MonthlyPayment++) { //print statement System.out.print("$200,000 principle, "); System.out.print(interest[MonthlyPayment]); System.out.print("% interest, "); System.out.print(term[MonthlyPayment]); System.out.print(" years, "); System.out.println("Payment "); System.out.print(nf.format(mortgages[MonthlyPayment])); System.out.println(""); System.out.println(pay[MonthlyPayment]); System.out.println(amort[MonthlyPayment]); } } } I'd be grateful for any help. Thank you. == 2 of 3 == Date: Thurs, Sep 16 2004 10:32 am From: Andrew Thompson <[EMAIL PROTECTED]> On 16 Sep 2004 10:03:24 -0700, Cassie wrote: > I am a student and am learning Java. You seem to be swimming Cassie. By the looks of this problem, your instructor expects you to understand method calls, loops, conditionals.. Your code displays little, if any of that understanding. One answer to your question is displayed in the following variant of your code. It displays defining and calling a method, and a switch statement (conditional). But we cannot run an entire Java course through usenet though, so you are going to need to hit the books and figure out what these changes mean. <sscce> //importing classes import java.lang.Math; import java.text.NumberFormat; // naming this class public class Array2exp { //calling Currency formatting static NumberFormat nf = NumberFormat.getCurrencyInstance(); public static double amortization(int years) { // do the amortization calcualations.. // .. blah, blah double amount; switch(years) { case 7: amount = 0.4; break; case 15: amount = 0.6; break; case 30: amount = 0.8; break; default: amount = -1.0; System.out.println("!! Logic Error !!"); } return amount; } public static double payment(int years) { // do the amortization calcualations.. // .. blah, blah return 1.0; } public static void main (String [] args) { // Array declration double mortgages []; double interest []; int term []; double amort []; double pay []; //Array creation mortgages = new double[3]; interest = new double [3]; term = new int [3]; amort = new double [3]; pay = new double [3]; // Array initialization mortgages [0] = (200000*5.35*(Math.pow((1+5.35/1200),84)))/(1200*(Math.pow((1+5.35/1200),84)-1)); mortgages [1] = (200000*5.5*(Math.pow((1+5.5/1200),180)))/(1200*(Math.pow((1+5.5/1200),180)-1)); mortgages [2] = (200000*5.75*(Math.pow((1+5.75/1200),360)))/(1200*(Math.pow((1+5.75/1200),360)-1)); interest [0] = 5.35; interest [1] = 5.5; interest [2] = 5.75; term [0] = 7; term [1] = 15; term [2] = 30; amort [0] = amortization(7); amort [1] = amortization(15); amort [2] = amortization(30); pay [0] = payment(7); pay [1] = payment(15); pay [2] = payment(30); //for loop, (initialization, expression, update) for (int MonthlyPayment=0; MonthlyPayment<=2; MonthlyPayment++) { //print statement System.out.print("$200,000 principle, "); System.out.print(interest[MonthlyPayment]); System.out.print("% interest, "); System.out.print(term[MonthlyPayment]); System.out.print(" years, "); System.out.println("Payment "); System.out.print(nf.format(mortgages[MonthlyPayment])); System.out.println(""); System.out.println(pay[MonthlyPayment]); System.out.println(amort[MonthlyPayment]); } } } </sscce> BTW, please do not cross-post. <http://www.physci.org/codes/javafaq.jsp#xpost> Since these sort of questions are best dealt with on c.l.j.help, I will set follow-ups to ge to that group alone. HTH -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.lensescapes.com/ Images that escape the mundane == 3 of 3 == Date: Thurs, Sep 16 2004 10:35 am From: Paul Lutus <[EMAIL PROTECTED]> Cassie wrote: > Arrays > I am a student and am learning Java. I am not allowed to use graphical > user interface, at this point. This is a Good Thing(tm). Using a GUI very often obscures the things you are trying to learn. > I MUST use an array to display 3 > mortgages; > 1.) 7 years, 5.35% interest, $200,000 principle > 2.) 15 years, 5.5% interest, $200,000 principle > 3.) 30 years at 5.75% interest, $200,000 principle This suggestion *will* help your grade: the word is spelled "principal". > I have accomplished this successfully BUT I also have to "list the > loan balance and interest paid for each payment over the term of the > loan". I am trying to call a payment and amortization method from 3 > separate programs (7year.java, 15year.java & 30year.java). Do you need to do it this way? Are you allowed to include the computations for these different scenarios in your program, or is the above a course requirement? About your program. You have all your code in a single method: main(). Try breaking your code up into individual methods, this will greatly ease the task of writing this or nearly any other program. > Is this possible? Do the programs need to be merged into one (this is > possible)? The question is whether you are permitted include the programs you describe. If so, then yes, this is a better approach. By the way, is using arrays a requirement? The problem you posed doesn't rewquire them. If the lesson is about using arrays, go ahead as you are doing, but if not, you may want to reconsider your approach. > (200000*5.35*(Math.pow((1+5.35/1200),84)))/(1200*(Math.pow((1+5.35/1200),84)-1)); > mortgages [1] = > (200000*5.5*(Math.pow((1+5.5/1200),180)))/(1200*(Math.pow((1+5.5/1200),180)-1)); > mortgages [2] = > (200000*5.75*(Math.pow((1+5.75/1200),360)))/(1200*(Math.pow((1+5.75/1200),360)-1)); > interest [0] = 5.35; Wow. Consider using program constants to describe the various parametes for your computation, and I certainly advise that you write at least one method to set up the mortgage initialization that you are now doing by copying a code line and changing some numbers, as above. > If this is not possible what is while using the array? Say again? -- Paul Lutus http://www.arachnoid.com ========================================================================== TOPIC: String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/39e65137dfea9036 ========================================================================== == 1 of 2 == Date: Thurs, Sep 16 2004 10:03 am From: [EMAIL PROTECTED] (Matt) What's the differences between the following: String[] files = {"a.doc, b.doc"}; and String[] files = new String[] {"a.doc, b.doc"}; I think similar question as: String file = "a.doc"; and String file = new String("a.doc"); == 2 of 2 == Date: Thurs, Sep 16 2004 10:26 am From: "Will Hartung" <[EMAIL PROTECTED]> "Matt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What's the differences between the following: > > String[] files = {"a.doc, b.doc"}; > and > String[] files = new String[] {"a.doc, b.doc"}; > I think similar question as: > > String file = "a.doc"; > and > String file = new String("a.doc"); The difference is more like this: public String getFile() { String file = "a.doc"; return file; } String a = getFile(); String b = getFile(); In the first case, a == b, in the second, they don't. With the arrays, I don't believe that Java will statically allocate the array using the first technique. Consider: public String[] getFiles() { String[] files = {"a.doc", "b.doc"}; return files; } String a[] = getFiles(); String b[] = getFiles(); If Java statically allocated the array, then you would see this: a == b If it creates the array anew with every method call, then they'd be different. Regards, Will Hartung ([EMAIL PROTECTED]) ========================================================================== TOPIC: Inserting components into a JTextPane http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8de30a108c9b450 ========================================================================== == 1 of 1 == Date: Thurs, Sep 16 2004 10:34 am From: [EMAIL PROTECTED] (Jonck van der Kogel) Hi everybody, I am trying to set up a JTextPane that will not only hold text but components as well. So what I want is for a user to be able to type some text in the JTextPane, then insert a component, type some more text, etc... The component that I want inserted only has a visual purpose, it should be a piece of gray text that cannot be edited. So the user should not be able to perceive any difference between the text that he/she typed and the text that is painted on the component aside from that the text on the component is gray and the normal text is black. I want it to be like this so that the user either has a certain component inserted or not, no individual letters of the component can be deleted. I'm using the insertComponent method of the JTextPane, but I'm not altogether sure what type of Java component I should use to paint on. I've tried overriding JLabel, JPanel and JComponent and so far only JComponent gave any results. The class looks like this (note it's only an experiment, so it's very basic): private class TextLabel extends JComponent { String message = "Test"; Font myFont = new Font("Lucida Grande", Font.PLAIN, 13); Dimension compDimensions; int width; int height; public TextLabel(String message) { this.message = message; setBackground(Color.WHITE); setForeground(Color.GRAY); FontMetrics metrics = getFontMetrics(myFont); width = metrics.stringWidth(message); height = metrics.getHeight(); compDimensions = new Dimension(width, height); } public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setFont(myFont); g2.drawString(message, width, height); } public Dimension getMinimumSize() { return compDimensions; } public Dimension getPreferredSize() { return compDimensions; } } Now when I use insertComponent method of JTextPane to insert my custom JComponent, the JComponent is much too big (the text is drawn correctly, but it has a lot of white space surrounding it). If I try to extend JLabel or JPanel nothing appears whatsoever. Does anybody have some tips for me how to get this working? Thanks very much, Jonck ========================================================================== TOPIC: simpleDateFormat and April month http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/383df9c88dcb10ba ========================================================================== == 1 of 2 == Date: Thurs, Sep 16 2004 10:40 am From: [EMAIL PROTECTED] (Nurettin Arslankaya) Hi, possibly, i had a bug to report. Here is sample code to test : public Date StrToDate(String DT) throws Exception { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return formatter.parse(DT); } When I test with fallowing data I got wrong result. 1980-04-01 00:00:00 returns 1980-04-01 01:00:00 1975-04-12 00:00:00 returns 1975-04-12 01:00:00 for the dates It works wrong for 1 hour. when you enter 1980-04-01 01:00:00 it works correct but if you enter 1980-04-01 00:30:00 it returns also 1 hour later time. possibly there are several dates that has problem. I am using jre 1.4. Does anyone know why it resulting wrong. == 2 of 2 == Date: Thurs, Sep 16 2004 10:45 am From: Paul Lutus <[EMAIL PROTECTED]> Nurettin Arslankaya wrote: > Hi, > > possibly, i had a bug to report. Here is sample code to test : > > public Date StrToDate(String DT) throws Exception { > SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd > HH:mm:ss"); > return formatter.parse(DT); > } That is not all the code you are using in your test. Please post a complete, short, working program. > When I test with fallowing data I got wrong result. > > 1980-04-01 00:00:00 returns 1980-04-01 01:00:00 Using what output routine? > 1975-04-12 00:00:00 returns 1975-04-12 01:00:00 > > for the dates It works wrong for 1 hour. when you enter 1980-04-01 > 01:00:00 it works correct but if you enter 1980-04-01 00:30:00 it > returns also 1 hour later time. > > > possibly there are several dates that has problem. I am using jre 1.4. > Does anyone know why it resulting wrong. No, no one knows. Why? You did not post your code. -- Paul Lutus http://www.arachnoid.com ========================================================================== TOPIC: Execute command on remote server http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aea2e27783906e46 ========================================================================== == 1 of 2 == Date: Thurs, Sep 16 2004 10:49 am From: "Sam Palanivel" <[EMAIL PROTECTED]> I know only two methods to execute commend in remote server: RMI and through web server: Is there any other method to execute command in remote server? Thanks Sam == 2 of 2 == Date: Thurs, Sep 16 2004 11:05 am From: Andrew Thompson <[EMAIL PROTECTED]> On Thu, 16 Sep 2004 13:49:43 -0400, Sam Palanivel wrote: > Is there any other method to execute command in remote server? Ring the SysOp. Offer beer. ;-) -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.lensescapes.com/ Images that escape the mundane ======================================================================= You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer". comp.lang.java.programmer [EMAIL PROTECTED] Change your subscription type & other preferences: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe Report abuse: * send email explaining the problem to [EMAIL PROTECTED] Unsubscribe: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe ======================================================================= Google Groups: http://groups-beta.google.com ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/BCfwlB/TM --------------------------------------------------------------------~-> <a href=http://English-12948197573.SpamPoison.com>Fight Spam! Click Here!</a> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/kumpulan/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
