comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Date parser for W3 "dateTime" format - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6199ffc5b402c29e * New String - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/480ebe0f50a46c11 * validation of document extension - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5096ebe0be27ad01 * ByteBuffer and arrays - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/670f596e0e700bac * Anyone experienced in express data with figures? - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/71746819ee3774a5 * Package java.net does not exist - 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/983a6c84929111be * [REPOST] java.awt.Image problem - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7f984034b7d7f294 * how to resize a array? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d5ed97c9d7b81add * A File as Entity Bean - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dc2ba965f5007a6f * A Record Class Type: Bad Style? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c123108701741bdf * opinion on coding standard - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1f96751a1d317c1a * Runtime.getRuntime().exec() doesn't return (?) - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/97faf78b55ba4d7f * Question regarding lycos VDS - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/12978f93dd03b5cd * searching strings - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d03e3ab90a0d69cb ============================================================================== TOPIC: Date parser for W3 "dateTime" format http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6199ffc5b402c29e ============================================================================== == 1 of 1 == Date: Wed, Dec 1 2004 2:59 pm From: "Ann" "Jacob" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Does anyone have the few lines of code for creating a > DateFormat of the W3 "dateTime" format: > http://www.w3.org/TR/xmlschema-2/#dateTime > ? > > It is almost straight forward, but a few optional > components must be accounted for, and there is an issue > on time zone as well. > > Thanks! Google says ;-) http://jigsaw.w3.org/Doc/Programmer/api/org/w3c/util/DateParser.html ============================================================================== TOPIC: New String http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/480ebe0f50a46c11 ============================================================================== == 1 of 2 == Date: Wed, Dec 1 2004 3:03 pm From: "Ann" "Michael Borgwardt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ann wrote: > > NOT TRUE about SUBSTRING: > > Yes, it is true. > > > here is the code from java/lang/String.java, it uses NEW > > Who said it doesn't? Not me. > > > --------------------- > > public String substring(int beginIndex, int endIndex) { > > if (beginIndex < 0) { > > throw new StringIndexOutOfBoundsException(beginIndex); > > } > > if (endIndex > count) { > > throw new StringIndexOutOfBoundsException(endIndex); > > } > > if (beginIndex > endIndex) { > > throw new StringIndexOutOfBoundsException(endIndex - beginIndex); > > } > > return ((beginIndex == 0) && (endIndex == count)) ? this : > > new String(offset + beginIndex, endIndex - beginIndex, value); > > } > > That's a NON-PUBLIC CONSTRUCTOR, and "value" is the char[] the > current string is based on, which is referred to in the new String, > not copied. > > Which has exactly the consequences I explained. 1. the word 'new' is used 2. the word 'public' is used Am I still confused? Does 'new' mean 'share'? Does 'public' mean 'NON-PUBLIC'? == 2 of 2 == Date: Wed, Dec 1 2004 4:09 pm From: Michael Borgwardt Ann wrote: >>> public String substring(int beginIndex, int endIndex) { >>> if (beginIndex < 0) { >>> throw new StringIndexOutOfBoundsException(beginIndex); >>> } >>> if (endIndex > count) { >>> throw new StringIndexOutOfBoundsException(endIndex); >>> } >>> if (beginIndex > endIndex) { >>> throw new StringIndexOutOfBoundsException(endIndex - beginIndex); >>> } >>> return ((beginIndex == 0) && (endIndex == count)) ? this : >>> new String(offset + beginIndex, endIndex - beginIndex, value); >>> } >> >>That's a NON-PUBLIC CONSTRUCTOR, and "value" is the char[] the >>current string is based on, which is referred to in the new String, >>not copied. >> >>Which has exactly the consequences I explained. > > > 1. the word 'new' is used I never disputed this. > 2. the word 'public' is used substring() is a public method. The String object it returns is created (your "new") with a non-public constructor. Which actually doesn't matter. > Am I still confused? Apparently. > Does 'new' mean 'share'? The underlying char array that actually contains the "String data" IS shared, because the constructor used to create the new String object simply copies the reference to it. Again, that (and nothing else) is what I said. ============================================================================== TOPIC: validation of document extension http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5096ebe0be27ad01 ============================================================================== == 1 of 1 == Date: Wed, Dec 1 2004 3:08 pm From: Andrew Thompson On 30 Nov 2004 05:43:13 -0800, Roy wrote: (snip) > ...the extenstion would > either be xls,doc,ppt, pdf, txt, or online/webform. > > Here is part of the code I have been working with. When you don't know why your code breaks, code snippets are slightly less than useless. 'Nothing' is useless, but snippets also take up bandwidth. ... > String[] rType = {".xls", ".doc", ".txt", ".pdf", ".ppt"}; Why is rType only mentioned once? You declare it and initialise it, but it do not reference it again in the snippets you supply.. .. > If anyone can help me please offer your input, some of the code has > been omitted for security purpose. Rewrite it to remove the secure code and post a self-contained example[1] that fails. ..It *does* fail, right[2]? [1] <http://www.physci.org/codes/sscce.jsp> [2] Your post does not actually mention.. a) The result of the code you have (including exact error messages). <http://www.physci.org/codes/javafaq.jsp#exact> b) The behaviour you expected, and how the observed bahaviour differs from that. c) A question. -- 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 ============================================================================== TOPIC: ByteBuffer and arrays http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/670f596e0e700bac ============================================================================== == 1 of 1 == Date: Wed, Dec 1 2004 7:12 am From: [EMAIL PROTECTED] (Jesper Sahner) Michael Borgwardt <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Jesper Sahner wrote: > >>Well, having five variables named a, b, c, d and e isn't an elegant way > >>to *represent* data. And your speed worries are totally unfounded. > >>Even if the language or API had syntactic sugar to do what you want, > >>it would end up doing one of these things. > > > > > > If you are reading data from a database-like file it is convenient, > > that the variables have "real" names instead of array-names. > > > > I do not agree on the last past. When putting a=x[0],...,e=x[4] you > > make a full copy of variables already existing in memory which > > shouldn't be necessary. > > Technically, you usually end up doing *multiple* such copies. It is > not a problem. > > > It should be possible to "map" between {a, b, > > c, d, e} and x[] without making a copy - like you would do, if you > > were using objects (multiple references to the same object). Guess the > > problem is, that you can't refer to primitive variables with "multiple > > names" in Java. > > You'd still be making copies of the *references*, which are just > as big as (if not bigger than) the values. > I am not sure about this. Let's say that you have an object with two references. Any manipulation on the object will take the same amount of time no matter if you have one or two references, because the references are just pointers to (the same) memory-address, while the object itself exist in only one "copy". Example: Point p,q; p=new Point(); q=p; p.x=5; - implies q.x=5 Usually it is the object itself that takes up memory, not the references, I think. In this small example p and q refer to the same object. It is the same functionality that I am looking for with primitive variables, but I don't think this is supported in Java (no pointers). > > But maybe you are right, that the "copying-procedure" is not very > > time-comsuming! > > Compared to the time it takes to read the stuff from disk, it's totally > insignificant - we're talking about a factor of ten thousand to one, > if not a million to one. ============================================================================== TOPIC: Anyone experienced in express data with figures? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/71746819ee3774a5 ============================================================================== == 1 of 3 == Date: Wed, Dec 1 2004 3:23 pm From: Andrew Thompson On 1 Dec 2004 06:59:01 -0800, wayne wrote: > What's the easiest way to express the data using a figure? For who? You or the user[1]? >..Anything > in a browser recognizable form would be fine, be HTML, applet, swing, applet and swing are not necessarily separate things. You can have.. - Applet - AWT - JApplet - Swing - Frame - AWT - JFrame - Swing - non-gui - neither AWT nor Swing. So, if you decide on an applet, your choice is then AWT or Swing. The advantages of AWT are that it is usable even back on version 1.1 JVM's. OTOH, Swing offers a components well suited to displaying simple HTML (JEditorPane), or the JTable class. Further, not every browser has Java installed. So if this data is anything beyond 'purely ancillary', you need to be able to fall back to pure HTML. > pdf, or even MS excel (in the end user side, not my server side). You're kidding aren't you? PDF is ridiculous overkill for this task and end users generally hate it. MS Excel is even sillier. Who are your end users? If they come 'off the net' then many of them will not have 'MS Excel' installed[2]. It is also a much more bloated format than HTML. [2] I am running XP Pro, but do not have MS Excel. Even Windows users are not guaranteed to be able to use an Excel format file. So, to sum up. [1] The user would be best off getting plain old HTML, since HTML is made for browsers and much a) lighter weight than the alternatives. b) more widely readable by browsers. 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 3 == Date: Wed, Dec 1 2004 11:13 am From: [EMAIL PROTECTED] (wayne) The end users are inside the company. Currently the data (in table form and dynamic)is displyed in JSP. I'd like the data displayed in 3 dimensional figure form. Since I have zero clue about any graphics programming, where do I start with? OK, no PDF or Excel. Thanks, Wayne Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > On 1 Dec 2004 06:59:01 -0800, wayne wrote: > > > What's the easiest way to express the data using a figure? > > For who? You or the user[1]? > > >..Anything > > in a browser recognizable form would be fine, be HTML, applet, swing, > > applet and swing are not necessarily separate things. > > You can have.. > - Applet - AWT > - JApplet - Swing > - Frame - AWT > - JFrame - Swing > - non-gui - neither AWT nor Swing. > > So, if you decide on an applet, your choice is then AWT or Swing. > The advantages of AWT are that it is usable even back on version > 1.1 JVM's. OTOH, Swing offers a components well suited to displaying > simple HTML (JEditorPane), or the JTable class. > > Further, not every browser has Java installed. So if this data > is anything beyond 'purely ancillary', you need to be able to > fall back to pure HTML. > > > pdf, or even MS excel (in the end user side, not my server side). > > You're kidding aren't you? > > PDF is ridiculous overkill for this task and end users generally hate it. > > MS Excel is even sillier. Who are your end users? If they come > 'off the net' then many of them will not have 'MS Excel' installed[2]. > It is also a much more bloated format than HTML. > > [2] I am running XP Pro, but do not have MS Excel. Even Windows users > are not guaranteed to be able to use an Excel format file. > > So, to sum up. > > [1] The user would be best off getting plain old HTML, > since HTML is made for browsers and much > a) lighter weight than the alternatives. > b) more widely readable by browsers. > > HTH == 3 of 3 == Date: Wed, Dec 1 2004 12:21 pm From: Andrew Thompson On 1 Dec 2004 11:13:13 -0800, wayne wrote: Please refrain from top-posting. Post in-line with trimming. <http://www.physci.org/codes/javafaq.jsp#netiquette> See further comments below. > Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL > PROTECTED]>... >> On 1 Dec 2004 06:59:01 -0800, wayne wrote: >> >>> What's the easiest way to express the data using a figure? ... >> So, if you decide on an applet, .. > The end users are inside the company. Make sure you mention that in any new post, it makes a HUGE difference. In which country is the company (yes, it is relevant). >..Currently the data (in table > form and dynamic)is displyed in JSP. I'd like the data displayed in 3 > dimensional figure form. Why did you not mention that? Please give all pertinent data and constraints in future, so the responders do not need to guess. >..Since I have zero clue about any graphics > programming, where do I start with? The best group for GUI matters.. <http://www.physci.org/codes/javafaq.jsp#cljg> Read the linked FAQ for graphics rendering tips, then make a new post to the GUI group. As a starter, the Graphics2D API could do what you want, but you *might* find a package such as JFreeChart does it with much less programming overhead on your part. 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 ============================================================================== TOPIC: Package java.net does not exist http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/983a6c84929111be ============================================================================== == 1 of 4 == Date: Wed, Dec 1 2004 5:29 pm From: Carlos Hello, i am trying to compile an application with Java Wirelees Toolkit 2.2 (which runs already with J2SE), but it tells me, that it is impossible to finde the package java.net. The message looks like:: C:\JavaWirelessToolkit22\apps\pmecarlos\src\ProfileReference.java:9: package java.net does not exist protected java.net.URI profileURL; C:\JavaWirelessToolkit22\apps\pmecarlos\src\ProfileReference.java:15: package java.net does not exist public ProfileReference(java.net.URI profileURL, int profileID) { ..... Anyone knows what can i do? Thanks. Carlos. == 2 of 4 == Date: Wed, Dec 1 2004 6:07 pm From: Andrea Desole I don't know the Java Wirelees Toolkit, but this is simply impossible. java.net is part of the runtime jar. If it is missing, you can't even start the compiler. How are you building your code? What tool, what compiler, what JDK? What happens if you just write a file of one line "import java.net.URI;" and then you javac it? Also, whatever tool you are using, can you try to add rt.jar to the classpath? Carlos wrote: > Hello, i am trying to compile an application with Java Wirelees Toolkit > 2.2 (which runs already with J2SE), but it tells me, that it is > impossible to finde the package java.net. > The message looks like:: > > C:\JavaWirelessToolkit22\apps\pmecarlos\src\ProfileReference.java:9: > package java.net does not exist > protected java.net.URI profileURL; > C:\JavaWirelessToolkit22\apps\pmecarlos\src\ProfileReference.java:15: > package java.net does not exist > public ProfileReference(java.net.URI profileURL, int profileID) { > ..... > Anyone knows what can i do? > Thanks. > Carlos. == 3 of 4 == Date: Wed, Dec 1 2004 6:24 pm From: Michael Borgwardt Andrea Desole wrote: > I don't know the Java Wirelees Toolkit, but this is simply impossible. Sure it's possible. > java.net is part of the runtime jar. on J2SE, it is. Not necessarily on J2ME, which this is about. >> Hello, i am trying to compile an application with Java Wirelees >> Toolkit 2.2 (which runs already with J2SE), but it tells me, that it >> is impossible to finde the package java.net. J2ME consists of different "profiles", which differ in what parts of the j2SE API devices with that profile support. java.net is supported on the CDC profile, but not on the CLDC or MIDP profiles. I haven't worked with the Java Wirelees Toolkit, so I can't tell you whether it allows development for CDC or not. == 4 of 4 == Date: Wed, Dec 1 2004 6:39 pm From: Andrea Desole Michael Borgwardt wrote: > > on J2SE, it is. Not necessarily on J2ME, which this is about. oh, okay. I thought it was running with the J2SE. I guess it's time to shut up :-) ============================================================================== TOPIC: [REPOST] java.awt.Image problem http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7f984034b7d7f294 ============================================================================== == 1 of 2 == Date: Wed, Dec 1 2004 3:49 pm From: "MaSTeR" > > It does repaint the buffer. Now if there are several threads accessing > > without sync the buffer but only one writing would it matter? Even if the > > buffer it's being written during a display operation a refresh lateron > > should redisplay it correctly... > > > > Yes - as long as a refresh does take place. But if you're triggering a > refresh only when a change has taken place, it may never be repainted. > It does, the ticker can be moved back and forth and that forces redrawing the buffer. Also iconizing it and refocusing it will repaint. > Also I assume you're also ensuring that the paint() method gets called > from the update() method. (i.e. if you're overriding update). > I do, the super class implementation clears the screen, causing flickering and it was unnecessary since my ticker repaints the whole area. Again I am stuck I can't get rid of this annoying bug. Anyway, thanks a lot for your time == 2 of 2 == Date: Wed, Dec 1 2004 10:03 pm From: Babu Kalakrishnan MaSTeR wrote: >>>It does repaint the buffer. Now if there are several threads accessing >>>without sync the buffer but only one writing would it matter? Even if > > the > >>>buffer it's being written during a display operation a refresh lateron >>>should redisplay it correctly... >>> >> >>Yes - as long as a refresh does take place. But if you're triggering a >>refresh only when a change has taken place, it may never be repainted. >> > > It does, the ticker can be moved back and forth and that forces redrawing > the buffer. Also iconizing it and refocusing it will repaint. > I think I lost you there. Do you mean to say that the display looks damaged even when you force a refresh by doing the above ?? I'd expect the display to become trashed as soon as it is updated from the other thread, and continue to be that way till something else (like the iconizing / restoring) forces it to refresh itself (at which point it should display properly). If this is the observed behaviour, that isn't very surprising at all. Proper synchronization should fix the issue. > >>Also I assume you're also ensuring that the paint() method gets called >>from the update() method. (i.e. if you're overriding update). >> > > I do, the super class implementation clears the screen, causing flickering > and it was unnecessary since my ticker repaints the whole area. > This means that the way you're performing double buffering is broken. The clearing of the screen is exactly what you *avoid* by using double buffering. Of course there is a limit to what one can speculate without seeing the relevant code. BK ============================================================================== TOPIC: how to resize a array? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d5ed97c9d7b81add ============================================================================== == 1 of 1 == Date: Wed, Dec 1 2004 4:33 pm From: bugbear Chris Uppal wrote: > bugbear wrote: > > >>I just looked at the 1.4 src for ArrayList >>The Object references are simply an array: >> >> private transient Object elementData[]; >> >>Where do you suggest the dozen bytes per member overhead >>is incurred? > > > It's a plausible (but implementation dependent) estimate in the case where the > elements of the array would be primitives, since you are forced to use object > wrappers to put them into an ArrayList. Ah! That would make sense. BugBear ============================================================================== TOPIC: A File as Entity Bean http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dc2ba965f5007a6f ============================================================================== == 1 of 1 == Date: Wed, Dec 1 2004 8:55 am From: [EMAIL PROTECTED] (indo3) HI How can I transactional wrap a file (on a local file system ) in an entity bean? I want a CMP but how to do that? Have i have to write a wrapper according to the JCA? How do i wrap other data sources which can not be reached via JDBC? THANKSS ============================================================================== TOPIC: A Record Class Type: Bad Style? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c123108701741bdf ============================================================================== == 1 of 1 == Date: Wed, Dec 1 2004 6:50 pm From: "George W. Cherry" "Ann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >> >> Indeed. The problem is that the user knows that the >> >> method returns the number of vowels, the number of >> >> consonants, and the number of other characters in >> >> the supplied string, but wouldn't know which element >> >> of the returned array referred to which count. >> >> >> > >> > Since you are the program author, you can tell her on the phone. >> >> API by telephone, huh? >> > Since your written explanation in the documentation is insufficient. Aha! You're right!. Since I don't like to share my telephone number with strangers, I better improve the documentation (as I have below). /** * Returns: * in return value int[0], the number of vowels in parameter str; * in return value int[1], the number of consonants in parameter str; * in return value int[2], the number of other characters in parameter str. */ public static int[] countVowelsConsonantsOthers(String str) { int vowels = 0, consonants = 0, others = 0; for (int j = 0; j < str.length(); j = j + 1) { char ch = str.charAt(j); if ( Character.isLetter(ch) ) { switch(ch) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'A': case 'E': case 'I': case 'O': case 'U': vowels++; break; //end cases for vowels default: consonants++; //end ch is a letter but not a vowel }//end switch statement } else { //ch is not a letter others++; } }//end for loop assert vowels + consonants + others == str.length(); return new int[]{vowels, consonants, others}; }//end countVowelsConsonantsOthers method What else could I do to make this tiny example less insane? (Huh, Chris)? George ============================================================================== TOPIC: opinion on coding standard http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1f96751a1d317c1a ============================================================================== == 1 of 2 == Date: Wed, Dec 1 2004 6:43 pm From: [EMAIL PROTECTED] (Gerbrand van Dieijen) On Tue, 30 Nov 2004 17:34:23 GMT, Ann wrote: > >In my experience in working at a large company, many decisions are made at >the Vice President level (under her is an Executive Director, then a >Department >head, then my lowly Supervisor) and my sup is not able to bang the doors >to make the VP change her mind even if she wanted to. Imagine 10 workers >in a group and 3 want tabs, 3 want spaces, and 4 want tabs and spaces. >I suppose that 6 or 7 of them should quit if they don't get their way. > I'm certain there are management books, which go in detail on this kind of subjects. I think the superviser/boss should listen to all arguments, critiques and use it to make his or her descision. Those 6 or 7 don't have to quit, most likely they get their way at another time. Maybe what is chosen, later doesn't seem to work well and they'll be listened to next time, or vice versa. -- Gerbrand van Dieijen == 2 of 2 == Date: Wed, Dec 1 2004 7:57 pm From: Michael Borgwardt Ann wrote: > In my experience in working at a large company, many decisions are made at > the Vice President level (under her is an Executive Director, then a > Department > head, then my lowly Supervisor) and my sup is not able to bang the doors > to make the VP change her mind even if she wanted to. What in god's grace is a *VP* doing micromanaging stuff like coding standards? ============================================================================== TOPIC: Runtime.getRuntime().exec() doesn't return (?) http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/97faf78b55ba4d7f ============================================================================== == 1 of 3 == Date: Wed, Dec 1 2004 8:04 pm From: Timo Nentwig final String cmd = "mycmd"; final Process proc = Runtime.getRuntime().exec( cmd ); final BufferedReader in = new BufferedReader(new InputStreamReader( proc.getInputStream() )); final StringBuffer buf = new StringBuffer(); for( String s; (s = in.readLine()) != null; ) buf.append( s ); System.out.println("done"); return buf.toString(); "done" is never printed and that is actually because the for loop never terminates. in.readLine() apparently never does return null. I assume some process termination problem or something. Somebody having a clue on this? Timo == 2 of 3 == Date: Wed, Dec 1 2004 2:36 pm From: "John C. Bollinger" Timo Nentwig wrote: > final String cmd = "mycmd"; > final Process proc = Runtime.getRuntime().exec( cmd ); > > final BufferedReader in = new BufferedReader(new > InputStreamReader( proc.getInputStream() )); > final StringBuffer buf = new StringBuffer(); > for( String s; (s = in.readLine()) != null; ) > buf.append( s ); > > System.out.println("done"); > > return buf.toString(); > > > "done" is never printed and that is actually because the for loop never > terminates. in.readLine() apparently never does return null. I assume some > process termination problem or something. > > Somebody having a clue on this? I'd bet that the for loop is blocking in BufferedReader.readLine(), presumably because the external process never terminates. Things to try: (1) proc.getOutputStrteam().close(); (2) make sure the process error output (proc.getErrorStream()) is drained in a separate thread. Both might be necessary. John Bollinger [EMAIL PROTECTED] == 3 of 3 == Date: Wed, Dec 1 2004 8:48 pm From: Timo Nentwig John C. Bollinger wrote: > I'd bet that the for loop is blocking in BufferedReader.readLine(), > presumably because the external process never terminates. Things to try: The command does terminate when launched in console... > (1) proc.getOutputStrteam().close(); When? ============================================================================== TOPIC: Question regarding lycos VDS http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/12978f93dd03b5cd ============================================================================== == 1 of 1 == Date: Wed, Dec 1 2004 11:11 am From: [EMAIL PROTECTED] (Markus Deibel) [EMAIL PROTECTED] (Frank Gerlach) wrote in message > I am using a "virtual dedicated server" (VDS) from lycos. > [...] > This is the url: http://webcenter.lycos.de/ Hi Frank, I'm thinking about getting one of these VDSs. What about the disk space? Do you have to install the OS on this 1 GB or is that separate? If I install sarge on that about 300-500 MB of my space are gone. Perhaps you could share some of your experience. Cheers Markus ============================================================================== TOPIC: searching strings http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d03e3ab90a0d69cb ============================================================================== == 1 of 2 == Date: Wed, Dec 1 2004 7:31 pm From: burchill I am trying to write a kind of parser program, it is supposed to analyse a guitar tab file (just a plain txt file). It should extract any chord names in the tab file by trying match any text in the tab file with any text in a list of chords in (another seperate file); So far I have loaded both files into string variables and am trying to search them using the regionMatches string method. The chords (a list of all chords) file is in this format... 466644 Absus 466644 Absus4 466644 G#sus 466644 G#sus4 545445 A11+ 545445 A9(#11) 545555 A7(#10) 545555 A7-10 557585 D7sus 557585 D7sus4 and so on... The numbers aren't important (they represent the fingering to play that chord). My main problem is that as you can see the chord names can vary in length (can be anything from 1 character up to 9). I am trying to write an algoritm that will take each chord name from the chord string and then search for it in the tab string. Each chord name starts on the 9th charcter on each line (including spaces as chararcters) but they don't all end at the same character on each line. Is there a way I can create a substring like this... tab.subSTring(8, end of line); Can I use the new line \n as a character to search for ? Any help appreciated. -- Eps == 2 of 2 == Date: Wed, Dec 1 2004 8:11 pm From: Andrew Thompson On Wed, 01 Dec 2004 19:31:23 +0000, burchill wrote: > Is there a way I can create a substring like this... > > tab.subSTring(8, end of line); > > Can I use the new line \n as a character to search for ? Use a StringTokenizer or String.split to change the single String to a String array, then loop through each array and ... String chord = strings[i].subString( 8, strings[i].length() ); BTW - best group for people beginning Java is.. <http://www.physci.org/codes/javafaq.jsp#cljh> 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 ============================================================================== You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer" group. To post to this group, send email to [EMAIL PROTECTED] or visit http://groups-beta.google.com/group/comp.lang.java.programmer To unsubscribe from this group, send email to [EMAIL PROTECTED] To change the way you get mail from this group, visit: http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe To report abuse, send email explaining the problem to [EMAIL PROTECTED] ============================================================================== Google Groups: http://groups-beta.google.com
