comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Java Event Listener integer problem. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/628a6e4b8e256d8d * Building Java Apps for Mobile Phones - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f7cac84d6b2aaed0 * How to create a JAR file - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ea455ce0dfc0c521 * Experienced programmer: where to start with Java? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/92371952fdc705d2 * Dynamic analysis tools information - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c85772c6b4c95756 * Help please - Why does ByteBuffer return '?' as opposed to what was put? - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d3036bb0e4e92e4 * Character encoding (2) - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8d7da38f00e609e9 * Reading resources from JAR file - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8337347a2d143e44 * Regular expression problem - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/98669b754907f080 * Java is EVIL, it's the programming language of SATAN ! ! ! - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/195bb46ec0ebeeea * NetBeans : How to change the color of the comments ? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d213a2c7db7604f5 * Inner Class in EJB not found - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d3fb4eb0ebb4e93d * Checking whether a string contains only ISO-8859-1 chars - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/759a4b422d12debc * Setting dynamic column value in PreparedStatement - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2a63ead6900be95e * emacs Vs Eclipse? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/58b6f53b3e1b91e1 * help with my first project on first job, how to read a strange file, thanks a lot!!!!!!! - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8c32ba1a17d68c9a * Newbee Question about random numbers - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d5332da2a87b1a4a * Oracle JDBC XA question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3ded1e7f0747a226 * J2SE 5.0 applet load time slow (animated gif the cause?) - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b27aadeefc35a092 * String reuse - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7689b54f75702319 ========================================================================== TOPIC: Java Event Listener integer problem. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/628a6e4b8e256d8d ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 2:06 am From: Michael Rauscher <[EMAIL PROTECTED]> Hi Cowboy, Mmm_moo_cows wrote: [...] > Every time I try and include a variable from the main gui class as a > counter I get an error message: > > 'local variable a is accessed from within inner class; needs to be > declared final' This message exactly describes your problem: you try to access a local variable from your inner class. Either you have to declare your variable final or you have to use an instance variable, e.g. class Gui { private int clicks = 0; public Gui() { } public JFrame createFrame() { JFrame frame = new JFrame("A new JFrame"); frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); JButton clickMe = new JButton("Click Me!"); frame.getContentPane().add(clickMe); frame.pack(); clickMe.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { clicks++; System.out.println("Clicked " + clicks + " times"); } } ); return frame; } public static final void main( String args[] ) { Gui gui = new Gui(); gui.createFrame().setVisible(true); gui.createFrame().setVisible(true); //2nd frame } } Bye Michael ========================================================================== TOPIC: Building Java Apps for Mobile Phones http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f7cac84d6b2aaed0 ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 2:23 am From: "Tim Ward" <[EMAIL PROTECTED]> "Lee" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If I bought the correct lead (either USB or serial) for my phone and > connected the phone to my PC how easy would it be to use java to access the > functions of the phone via the lead? Ideally I would like to send SMS > messages from my PC. (1) Find the documentation for your phone. (2) Read it. (3) Acquire any necessary driver software. (4) Write any necessary interface code to connect the driver to Java in a real language. ... of which (1) is likely to be the most difficult step. I would expect there to be a wide variety of mechanisms by now - last time I did this sort of thing some phones implemented an AT-style modem interface, with extended AT commands to send SMSs; this would typically require no low-level software on the PC beyond what you need to talk to the serial port, all the AT protocol handling can be done in Java. -- Tim Ward Brett Ward Limited - www.brettward.co.uk ========================================================================== TOPIC: How to create a JAR file http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ea455ce0dfc0c521 ========================================================================== == 1 of 2 == Date: Mon, Oct 25 2004 2:25 am From: Andrew Thompson <[EMAIL PROTECTED]> On 25 Oct 2004 01:20:13 -0700, Samar Hossam wrote: > Hi Andrew > >> How many groups do you intend to multi-post this >> question to Samar? Please don't multi-post. > > Well, I urgently needed help concerning the posted problem. That is nobody's problem but yours. These are discussion forums, not your personal help-desk for urgent problems. >..That's why > I sent it to two groups only. When (rarely) posting to multiple groups, x-post rather than multi-post.. <http://www.physci.org/codes/javafaq.jsp#xpost> >..(comp.lang.java.programmer & > comp.lang.java.help) Your question is best suited to c.l.j.help at this stage. > > Besides, it is not my problem that u've subscribed to several groups. > Finally, your reply to someone in need was veryyyyyyyyyyyy .. Please fix your <http://www.physci.org/kbd.jsp?key=y> key, it seems stuck. > ..mean. Your pitiful pleas are very boring. -- 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 2 == Date: Mon, Oct 25 2004 2:57 am From: Thomas Weidenfeller <[EMAIL PROTECTED]> Samar Hossam wrote: > Well, I urgently needed help concerning the posted problem. Then pay someone to do your work. We are not your free helpdesk. /Thomas ========================================================================== TOPIC: Experienced programmer: where to start with Java? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/92371952fdc705d2 ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 2:31 am From: Andrew Thompson <[EMAIL PROTECTED]> On 25 Oct 2004 10:18:58 +0200, Tor Iver Wilhelmsen wrote: >> - 3D modelling > > No, the Java3D API has native components that don't install easily > into an applet environment. Try these.. <http://www.1point1c.org/model/index.jsp?mdl=orb&mag=50&offsetx=0&rotx=1&roty=-1> <http://www.1point1c.org/model/index.jsp?mdl=cv&mag=35&offsetx=25&rotx=-8&roty=3> Java 1.1 compatible, powered by LiveGraphics3D <http://wwwvis.informatik.uni-stuttgart.de/~kraus/LiveGraphics3D/> -- 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: Dynamic analysis tools information http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c85772c6b4c95756 ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 2:36 am From: [EMAIL PROTECTED] (vipindeep) Dear reader, Are there any widely used dynamic analysis tools which are used for detecting errors in programming, for example null dereferences, deadlocks, etc.. Some of the tools which I could know are Daikon, *J, MAc JAVA, Delta Debuggers. Infact all these tools provide runtime information. Are there any tools like Purify (in C for memory based errors, array out of bounds etc). Can any one give information regarding the runtime analysis tools for error detection in C++ and JAVA. Thanks, Vipin ========================================================================== TOPIC: Help please - Why does ByteBuffer return '?' as opposed to what was put? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d3036bb0e4e92e4 ========================================================================== == 1 of 3 == Date: Mon, Oct 25 2004 2:58 am From: [EMAIL PROTECTED] (Ed) All, I have an annoying problem with ByteBuffer (BB). I am reading from a telnet server - telnet sends bytes that can be any hex value, some have special meaning to telnet. I have the following code: for (int i = 0; i < 255; i++) { ch = (char) i; test = new StringBuffer(); test.append((char) i); byteBuffer.put(test.toString().getBytes()); byteBuffer.flip(); back = byteBuffer.get(); // Uncomment below to see more working ... /* if (back < 0) { System.out.println("... adding 256 ...."); back = back + 256; } */ backch = (char) back; if (ch != backch) { System.out.println("ERROR - following do not match:"); } System.out.println("" + i + " [" + ch + "] = " + back + " [" + backch + "]"); byteBuffer.clear(); } The code works ok up to value 127. From 129 to 159 (hex 80 to 9F) bytebuffer always gives back the '?' char (int 63). From 160 to 255 I get a negative number. You will see the commented out code - adding that solves the problem of 160 to 255 but I still get the 63 in the 129 to 159 range. I am obviously doing something wrong. Any help would be much appreciated. regards Ed == 2 of 3 == Date: Mon, Oct 25 2004 6:20 am From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> [EMAIL PROTECTED] (Ed) writes: > I have an annoying problem with ByteBuffer (BB). Rather with the understanding of how SIGNED bytes work. (Deleted insanely convoluted way of doing something) > back = byteBuffer.get(); Are we supposed to guess at the type of back? It it char? int? > if (back < 0) > { > System.out.println("... adding 256 ...."); > back = back + 256; > } See, the need to do this is indicative of your misunderstanding. > The code works ok up to value 127. Yes, that is Byte.MAX_VALUE. > From 129 to 159 (hex 80 to 9F) > bytebuffer always gives back the '?' char (int 63). There are no printable characters in that range, so they are substituted with a ?. > From 160 to 255 I get a negative number. Yes, signed bytes do that to you when the 8th bit is set. > You will see the commented out code - adding that solves the problem > of 160 to 255 but I still get the 63 in the 129 to 159 range. That's because you're supposed to. char charValue = (char) (byteValue && 0xff); should be somewhere in every Java IO tutorial. That said, you probably also need to consider specifying charset somewhere along the line. == 3 of 3 == Date: Mon, Oct 25 2004 6:27 am From: "Tim Ward" <[EMAIL PROTECTED]> "Tor Iver Wilhelmsen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [EMAIL PROTECTED] (Ed) writes: > > > I have an annoying problem with ByteBuffer (BB). > > Rather with the understanding of how SIGNED bytes work. Yet another victim of the utterly bizarre decision to make bytes signed in the first place. -- Tim Ward Brett Ward Limited - www.brettward.co.uk ========================================================================== TOPIC: Character encoding (2) http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8d7da38f00e609e9 ========================================================================== == 1 of 2 == Date: Mon, Oct 25 2004 3:16 am From: [EMAIL PROTECTED] Hello again, Sorry for posting this again, but since my thread of last saturday kind of ended on a dead track, I decided to post it brand new. Refer also to: http://groups-beta.google.com/group/comp.lang.java.programmer/messages/b7b2b45a08c061be,ec17d4b601945018,3eceec02b0896b7c,f0e7b3ee107fcf1a,cd38a8271be2326a,52d63db5f38d09f7,6b717f39e86c4e4a?thread_id=d00907704bee1888&mode=thread&noheader=1#doc_b7b2b45a08c061be The problem I'm having is basically only on the server side... I'm working on a server that should receive HTTP requests. It is however possible that the request that arrives at the server is not HTTP. This possibility is verified on the first byte of data. (in other words: if the first byte is equal to 0x01, then not HTTP else ... ) Given that the information is posted according to HTTP, I'm trying to resolve the following: I don't know a priori which encoding is used for the data stream. The following rules for encoding apply: If the string (using regex) <?xml [^>]+encoding="([^"]+)" is encountered, $1 is used for decoding, otherwise a default char set is used. My goal is to both use the characters (i.e. the server's 'interpretation' of the bytes received) as the original byte stream. I want to write to a file the original byte stream, while using the derived character stream for processing (using beans, XSL transformation etc.) I tried simulating the client using a basic HTML page, with a FORM action to my server's url. Now in HTML I can specify the meta element Content-type, and set it to "text/xml; charset=utf-8 or whatever I like. I recall that by default HTML Forms encode using the platform default charset and content-type application/x-www-form-urlencoded Also tried to simulate the client with a JAVA application that makes use of the java.net.HttpURLConnection. Here I have set the requestProperty "Content-type" to "text/xml; charset=utf-8". Now I'm not sure whether in either one or both cases the stream is mime encoded...? Someone in the previous thread suggested me to use HttpURLConnection also on the serverside, but since I'm expecting also non-HTTP requests, I'm not sure if I can. Most likely I cannot use a BufferedReader, because it is based on a character stream, so I lose the original byte stream... Thx == 2 of 2 == Date: Mon, Oct 25 2004 3:32 am From: [EMAIL PROTECTED] Actually, rereading my post, I would like to add: I want to write to a file the original byte representation of characters after having processed them. The bean object(s) I'm using have their own write() method, which writes to an outputstream. I guess the solution here is remind what was the original encoding, use the bean's write method to write to a ByteArrayOutputStream, and then parse that to a String using platform default encoding, and then rewrite that using the original encoding to the file output stream... right? ========================================================================== TOPIC: Reading resources from JAR file http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8337347a2d143e44 ========================================================================== == 1 of 2 == Date: Mon, Oct 25 2004 3:29 am From: "MikL" <[EMAIL PROTECTED]> The following code works fine when the resource is a free-standing file, but when it's packaged up in a JAR it can't find it. What methods should I use to read it from a JAR? BufferedReader r = new BufferedReader( new InputStreamReader( getClass().getResourceAsStream("clientSchema.sql"))); == 2 of 2 == Date: Mon, Oct 25 2004 3:48 am From: Andrew Thompson <[EMAIL PROTECTED]> On Mon, 25 Oct 2004 20:29:26 +1000, MikL wrote: > The following code works fine when the resource is a free-standing file, but > when it's packaged up in a JAR it can't find it. Where in the jar do you put it? How do you reference it? >..What methods should I use > to read it from a JAR? > > BufferedReader r > = new BufferedReader( > new InputStreamReader( > getClass().getResourceAsStream("clientSchema.sql"))); What do you do with the exceptions you are getting? In any case, break this down and find the resource first. // ensure the capitals are exactly the same URL resource = getClass()("clientSchema.sql"); System.out.println("URL to resource: " + resource ); BufferedReader r .. -- 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: Regular expression problem http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/98669b754907f080 ========================================================================== == 1 of 3 == Date: Mon, Oct 25 2004 3:33 am From: [EMAIL PROTECTED] (Sky Wong) I would like to match this pattern <title>(any character including chinese except '<' and '>')</title> e.g. 1) <title>一二三</title> --> should be matched 2) <title>一二<三</title> --> should not be matched I can match both (1)&(2) by this Regular expression: <title>[\P{Cn}]*</title>, but after I change to RE to <title>[\P{Cn}-[<>]]*</title> (minus the '<' and '>'), (2) still can be matched, I don't know why. would someone help me to change the RE so that it can distinguish (1) and (2)? == 2 of 3 == Date: Mon, Oct 25 2004 3:36 am From: [EMAIL PROTECTED] (Sky Wong) I would like to match this pattern <title>(any character including chinese except '<' and '>')</title> e.g. 1) <title>一二三</title> --> should be matched 2) <title>一二<三</title> --> should not be matched I can match both (1)&(2) by this Regular expression: <title>[\P{Cn}]*</title>, but after I change to RE to <title>[\P{Cn}-[<>]]*</title> (minus the '<' and '>'), (2) still can be matched, I don't know why. would someone help me to change the RE so that it can distinguish (1) and (2)? == 3 of 3 == Date: Mon, Oct 25 2004 3:48 am From: [EMAIL PROTECTED] How I see it, is that you're specifying in your adjusted RE that it should match an expression between <title> and </title> that contains: Chinese characters; the character '-' ; the characters '<' and '>'. Try using <title>[^<]*</title>. Piet ========================================================================== TOPIC: Java is EVIL, it's the programming language of SATAN ! ! ! http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/195bb46ec0ebeeea ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 4:05 am From: [EMAIL PROTECTED] (Dave Monroe) [EMAIL PROTECTED] (Karl-Hugo Weesberg) wrote in message news:<[EMAIL PROTECTED]>... > Java is EVIL, it's the work of the devil, made to collect your > souls and to turn you into brainless slaves of hell. > > If you like Java, you will lose your soul to be damned > for eternal torment in hell.Demons and devils will feast on your soul > for all eternity. > > So stop using it now to save your soul. > > Or the holy inquisition will come for you and burn your flesh to save > your soul, because the devil must not collect more souls or nobody can > prevent Armageddon. > > Java is evil, using it is BLASPHEMY , only heretics and > witches like Java.And heretics and witches shall BURN ! > > Java = programming language written by SATAN in Hell's Kitchen in 666 minutes ! ! ! Thank you for a fair, balanced and well reasoned presentation. Isn't it time for your medications? ========================================================================== TOPIC: NetBeans : How to change the color of the comments ? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d213a2c7db7604f5 ========================================================================== == 1 of 2 == Date: Mon, Oct 25 2004 4:47 am From: [EMAIL PROTECTED] (JPR105) Europe - Belgium - 25th october 2004 - 14h12 Hi, I would like to change the color of the comments in NetBeans 3.6 because when I print my code (black and white) they appear grey. I would like a dark printing for these comments. Thank you very much for your help ! JPR ( Jean-Pierre ) == 2 of 2 == Date: Mon, Oct 25 2004 4:54 am From: Thomas Weidenfeller <[EMAIL PROTECTED]> > NetBeans http://www.netbeans.org/community/lists/ /Thomas ========================================================================== TOPIC: Inner Class in EJB not found http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d3fb4eb0ebb4e93d ========================================================================== == 1 of 3 == Date: Mon, Oct 25 2004 5:11 am From: Bruno Grieder <[EMAIL PROTECTED]> Hi, I have a stateless session bean which contains an inner class. When deplying to JBoss I get a java.lang.NoClassDefFoundError on my inner class. Is there anything I must put in the descriptor? Many Thanks bruno == 2 of 3 == Date: Mon, Oct 25 2004 5:39 am From: Bruno Grieder <[EMAIL PROTECTED]> I think I now qualify for the Darwin awards. The inner class is in a separate file and my doclet configuration only included the *Bean.class files That is what happens with too comfortable IDEs! Time to go back to vim ;-) bruno Bruno Grieder wrote: > Hi, > > I have a stateless session bean which contains an inner class. > > When deplying to JBoss I get a java.lang.NoClassDefFoundError on my > inner class. > > Is there anything I must put in the descriptor? > > Many Thanks > bruno == 3 of 3 == Date: Mon, Oct 25 2004 6:46 am From: Andrew Thompson <[EMAIL PROTECTED]> On Mon, 25 Oct 2004 14:39:37 +0200, Bruno Grieder wrote: > I think I now qualify for the Darwin awards. Given the 'late' state you need to be in - to qualify for those awards, I certainly hope not. > That is what happens with too comfortable IDEs! > Time to go back to vim ;-) Ah yes, a bit of tangling with the command line will restore your (vim and) vigour. ;) -- 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: Checking whether a string contains only ISO-8859-1 chars http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/759a4b422d12debc ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 5:45 am From: Jonck <[EMAIL PROTECTED]> Thomas and Chris, thanks to you both for your suggestions, both of your solutions work perfectly. ========================================================================== TOPIC: Setting dynamic column value in PreparedStatement http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2a63ead6900be95e ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 5:54 am From: "John B. Matthews" <[EMAIL PROTECTED]> In article <[EMAIL PROTECTED]>, Sudsy <[EMAIL PROTECTED]> wrote: > Anythingcan wrote: > > Hi gurus, > > > > The following two sql statements delete all entries in a database. > > > > 1) DELETE FROM table_name; > > 2) DELETE FROM table_name WHERE column = column; > > > > However, I would like my java code to only make use of option 2 so > > that I can use it to delete all entries AND specific entry using a > > PreparedStament, as follows: > > > > con.prepareStatement("DELETE FROM table_name WHERE column = ?"); > > > > If I want to delete 'a', the code would be: > > > > pstmt.setSring(1, "a"); > > pstmt.execute(); > > > > But what is the code to delete all the entries. > > This isn't a Java question; it's pure SQL. And while there are > wildcards in standard SQL, it's not going to help you in this > case. Your equivalency test will fail with wildcards. You'd have > to use the LIKE qualifier, which might have other unintended > consequences if you incorporate that into the prepare statement. > > Better to refer to a good SQL reference tome. Indeed. As an alternative, look at the "TRUNCATE table_name" command. -- John ---- jmatthews at wright dot edu www dot wright dot edu/~john.matthews/ ========================================================================== TOPIC: emacs Vs Eclipse? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/58b6f53b3e1b91e1 ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 6:09 am From: Galen Boyer <[EMAIL PROTECTED]> On Sun, 24 Oct 2004, [EMAIL PROTECTED] wrote: > What is artist-mode? A mode for creating ascii art. -- Galen Boyer ========================================================================== TOPIC: help with my first project on first job, how to read a strange file, thanks a lot!!!!!!! http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8c32ba1a17d68c9a ========================================================================== == 1 of 2 == Date: Mon, Oct 25 2004 6:30 am From: [EMAIL PROTECTED] (matt) here is a sample of the file. 2004-10-21 12:51:06 10.10.1.6 - 10.10.1.3 80 GET /test.html:1256 - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 12:51:10 10.10.1.6 - 10.10.1.3 80 GET /test.html:12534 - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 13:55:50 10.10.1.6 - 10.10.1.3 80 GET / - 403 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 13:55:53 10.10.1.6 - 10.10.1.3 80 GET /aseere - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 13:55:57 10.10.1.6 - 10.10.1.3 80 GET /aseegegeg - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 13:56:03 10.10.1.6 - 10.10.1.3 80 GET /aseegegggeegergeg - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 13:56:07 10.10.1.6 - 10.10.1.3 80 GET /asegegeegegegegggeegergeg - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 13:59:08 10.10.1.6 - 10.10.1.3 80 GET /grgejihghewgho - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 13:59:15 10.10.1.6 - 10.10.1.3 80 GET /grgejihghewghos - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 13:59:18 10.10.1.6 - 10.10.1.3 80 GET /grgejihghewghossaf - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 14:03:05 10.10.1.6 - 10.10.1.3 80 GET /12 - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 14:03:09 10.10.1.6 - 10.10.1.3 80 GET /1234 - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 14:09:24 10.10.1.6 - 10.10.1.3 80 GET /1234gt - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 2004-10-21 14:21:17 10.10.1.6 - 10.10.1.3 80 GET /1234gtffffff - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) this is IIS log file. i am not sure how to make hexdump. but the white space is space bar. thanks a lot Alex Hunsley <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Paul Lutus wrote: > > matt wrote: > > > > > >>Java guys: > >>this is my first project at my first job. so pls help if you could. > >>i am working with a text file with strange format. The file has a lot > >>of white space between the last line of valid text and the end of > >>file character. And the file is update frequently. New valid text is > >>appended behind the original valid text and overwrite some whitespace. > >> I need to feed this file as an input to an application. but this > >>application only take files without such whitespace. The application > >>need to read the file frequently to see whether new text is appended. > >>if there is, get the appended text. > > > > > > First things first. Explain exactly what the file consists of. Do not > > describe it, show it. > > OP: To add to that: as well as pasting the text of the file (or a > pertinent example), a hexdump to show the actual bytes would be useful. > (Or else we don't know what the whitespace we're seeing actually is - > tabs, spaces, weird chars etc.) > > alex == 2 of 2 == Date: Mon, Oct 25 2004 6:43 am From: [EMAIL PROTECTED] (matt) the OS is mainly windows. i doubt windows has powerful tool to do the job automatically. i need to open and close the file frequently because another process is writing to the file. then Java create a new object each time I open the file. in this case, can the program remeber the position I set last time? if yes, can i do the same thing with BufferedReader class instead of RandomAccessFile. i am not sure whether RandomAccessFile can easily allow me to keep the new line characters and white space among the valid text. i need these chars in the application. The length() can not help me a lot, since the file size does not change when new text is written into the file. the new text write over the whitespace but do not change the file size. thanks again! Alex Kizub <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > You didn't mention OS. Probably it could be solved only by OS tools. > For example for UNIX like it could be grep, tail -f, awk... |, > > > Java has other features, but since you can't change application and should > only change the file (which is not good solution itself) here are some > solutions for you. > > Use java.io.RandomAccessFile. > So you can set position which you alreadu reached with method seek, you > can know length of new open file with method > length(). > Then, I suggest, read file with method read(byte[] b) copy none white > spaces to another array and write it to the new file. > Pretty easy. > > BTW. With java.io.File you can understand last modification time and > decide do you need reread file again. > > Good luck in your new job. > Alex Kizub. > matt wrote: > > > Java guys: > > this is my first project at my first job. so pls help if you could. > > i am working with a text file with strange format. The file has a lot > > of white space between the last line of valid text and the end of > > file character. And the file is update frequently. New valid text is > > appended behind the original valid text and overwrite some whitespace. > > I need to feed this file as an input to an application. but this > > application only take files without such whitespace. The application > > need to read the file frequently to see whether new text is appended. > > if there is, get the appended text. > > My initial solution is to convert the original file into a new file in > > which the whitespace is truncated. then the application can read the > > new file. > > possibility 1: > > loop > > read 1 line of text of original file > > write this line to new file > > until read the long line of white space > > close both file > > > > in this case, what class and method should i use, especially in > > examing the white spaces? > > > > possibility 2: > > the previous one is not smart because the same text is read and write > > each time when the file is read. so is there a way i can just each > > time check whether update happens to the file and then just write the > > update to the new file? such as in C, a file pointer know the position > > of last read. can i do the same in Java or C#? or other ways to do it? > > possibility 3: > > very unlikely but smarter, > > read the file in a stream, truncate the whitespace inside the > > stream, then feed the stream directly into the application. but it is > > unlikely because i can not change the souce code the application. > > > > any other possibilies to solve this problem? > > for all the possibilities, pls tell me what class and method should i > > use, sample code and website is extremely helpful. > > thanks a lot!!!!! ========================================================================== TOPIC: Newbee Question about random numbers http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d5332da2a87b1a4a ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 6:29 am From: "J.F. Cornwall" <[EMAIL PROTECTED]> Jacob wrote: > marcus wrote: > >> it is a kind of thing in this ng to not give homework answers > > > There is no such "kind of thing". > > If you don't like to post answers to assignments, then > don't. Others will decide for themselves what to do. > > Anyone can ask questions or launch discussions. If the > feedback solves an academic or an enterprise problem > should be the same. > > In general: Respond to *good* problems and ignore *bad* > ones. This encourage good questions and discussions and > will keep the quality of the stream high in the long run. > Seems to me that the pointer to information was a good answer. It did *not* provide the student with code that does his work for him, it gave him something to look at so he can implement it on his own. Geez.... Jim C ========================================================================== TOPIC: Oracle JDBC XA question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3ded1e7f0747a226 ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 6:34 am From: [EMAIL PROTECTED] (Guy Pardon) Hi, [EMAIL PROTECTED] (spiderbug) wrote in message news:<[EMAIL PROTECTED]>... > Hello, > While using the Oracle (Java)XA interfaces, I came across this > situation- > > 1. Start a transaction, enlist the connection in it (Effectively get > an XAConnection from an XADataSource, get the XAresource and call > start on it with some Xid). > 2. Perform some DB operations/queries on the java.sql.Connection > obtained from the XAConnection. > 3. End the transaction (not commit it, just xaresource.end) - with > flag TM_SUCCESS > 4. Perform some other operations/queries on the same JDBC connection > as in 2. > > Operation (4) fails with the error - java.sql.SQLException: Not in a > transaction. Now my question is - since I've already demarcated the > transactional boundaries with the start and end calls on the > XAresource, why cannot I perform any other operations outside the > transaction even if I've not committed the tx? The JTA spec says these > two calls are supposed to do just that. Is it an Oracle specific > problem or am I missing a point here? > > Thanks in advance > ~spiderbug~ Oracle deviates from the standard XA/JTA specs in the sense that it rejects any other transaction on the connection until you effectively commit or rollback the previously started XA transaction. More specifically: Oracle requires the following on the XAConnection/XAResource: start ( xid1 ); end ( xid1 ); //optional prepare ( xid1) commit ( xid1 ) or rollback ( xid 1 ) //only now start another tx start ( xid 2 ); ... Whereas the XA/JTA specs explicitly state that the following is legal: start ( xid1 ); end ( xid1 ); start ( xid2 ); commit ( xid1 ); I am afraid this is something you'll have to live with;-) Best, Guy http://www.atomikos.com: The Transaction Management Company ========================================================================== TOPIC: J2SE 5.0 applet load time slow (animated gif the cause?) http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b27aadeefc35a092 ========================================================================== == 1 of 2 == Date: Mon, Oct 25 2004 6:52 am From: [EMAIL PROTECTED] (Rob Cox) Folks, I have an applet (https), with about 5 MB of jar files. After we moved to J2SE 5.0, the load time seems much slower. It seems to have gone from about 40 seconds to 1 min 40 sec (approx). An odd thing I noticed is when I minimize my Internet Explorer window, the applet seems to start up quickly again. Is this possibly related to the "starburst logo" progress bar animation that Sun now uses for applet start ups? I know that animated gifs can sometimes chew up quite a bit of cpu time. I think the progressbar property is no longer in 5.0 I'm running on a single proc laptop. When I run it on my 2 proc server, it is not as obvious. Thanks, Rob == 2 of 2 == Date: Mon, Oct 25 2004 7:02 am From: Andrew Thompson <[EMAIL PROTECTED]> On 25 Oct 2004 06:52:45 -0700, Rob Cox wrote: > I have an applet .. URL? >..(https), Move it to an http if necessary. >..with about 5 MB of jar files. What does this applet do, neurosurgery? [ ;-) ] >..After we > moved to J2SE 5.0, the load time seems much slower. It seems to have > gone from about 40 seconds to 1 min 40 sec (approx). Time it, rather than estimate. > An odd thing I noticed is when I minimize my Internet Explorer window, > the applet seems to start up quickly again. Again with the 'seems'. *Time* *it*. System.out.println("start " + new Date()); > Is this possibly related to the "starburst logo" progress bar > animation that Sun now uses for applet start ups? Possibly yes, possibly no. Drag the applet out for public viewing, but put some timing debug statements in it first. What's the minimum Java required? -- 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: String reuse http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7689b54f75702319 ========================================================================== == 1 of 1 == Date: Mon, Oct 25 2004 7:00 am From: "John C. Bollinger" <[EMAIL PROTECTED]> Lee Fesperman wrote: > John C. Bollinger wrote: >>The class String maintains a pool of unique Strings, to which >>String.intern() method may add a String when invoked. References to >>compile-time constant Strings are guaranteed to refer to an interned >>String. However, as I was recently made aware, otherwise unreferenced >>String instances can be GC'd from the intern pool ("can" in the sense >>that recent Sun JVMs can be observed to do so), so it is not in general >>safe to assume that the String instance representing a particular >>compile-time constant String at one point in your program's execution >>is the same instance that represents the same or an equal String at some >>other point in your program's execution. Whether this is a reasonable >>behavior is subject to debate, but the fact that Sun's own JVM exhibits >>it makes the question rather moot. > > > Of course, my article was just to point out to Tony that the pool does exist. > However, > you bring up a good issue for discussion. I had assumed that the string pool never > shrunk. > > Thinking about it, it seems to be a good optimization for the JVM to make. > Generally, an > application couldn't even tell that unreferenced strings were dropped from the pool. > The > only ways to detect it would be to use WeakReference's, etc. or to retain the > identityHashCode for an intern'ed string for later checking. The latter is not > guaranteed to work, though. FWIW, The test code I have seen that demonstrates the Sun VM behavior in fact uses the identityHashCode technique. I was surprised, too, to find that interned Strings were being GCd. My initial reading of the JLS led me to think that they would not be GC'd, but the behavior does not seem to be forbidden. As it takes rather extraordinary means to detect the situation, I'm not loosing any sleep over it. John Bollinger [EMAIL PROTECTED] ======================================================================= 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
