Prev: Facing exception: Invalid byte 2 of 4-byte UTF-8 sequence.
Next: redirect System.out to JTextArea
From: Lew on 22 Jan 2010 23:12 Lew wrote, quoted or indirectly quoted someone who said : >>> =A0 =A0 =A0 =A0 =A0 =A0 in =3D new BufferedReader(new InputStreamReader(n= Roedy Green wrote: > those A0s are s > char( 160 ); > > Agent quietly converted them to ordinary spaces, but I gather's Lew's > newsreader converter them to =A0 > > Newsreaders tend to be pretty flat footed when interpreting text. Best > to keep your posts to printable ASCII. My newsreader displays those as spaces. -- Lew
From: John B. Matthews on 23 Jan 2010 00:04 In article <hjdsgh$2tt$2(a)news.albasani.net>, Lew <noone(a)lewscanon.com> wrote: > Lew wrote, quoted or indirectly quoted someone who said : > >> Why in the world would you assign to 'null' first, then discard that > >> initialization immediately? > > Roedy Green wrote: > > If you use IntelliJ, it quickly slaps your wrist for any unnecessary > > initialisation. > > Doesn't FindBugs also report that sort of thing? I don't see it: <http://findbugs.sourceforge.net/bugDescriptions.html> -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews>
From: Roedy Green on 23 Jan 2010 01:17 On Thu, 21 Jan 2010 06:05:30 -0800 (PST), saif al islam <saifzahur(a)gmail.com> wrote, quoted or indirectly quoted someone who said : > FileInputStream f =3D new FileInputStream( "fileName" ); What you preparing your posts with that is writing =3D for =? The are free newsreaders. See http://mindprod.com/jgloss/newsreader.html -- Roedy Green Canadian Mind Products http://mindprod.com If we have learned one thing from the history of invention and discovery, it is that, in the long run � and often in the short one � the most daring prophecies seem laughably conservative. ~ Arthur C. Clarke (born: 1917-12-16 died: 2008-03-19 at age: 90)
From: Kevin McMurtrie on 23 Jan 2010 01:19 In article <f0bgl5ldr1nes1gpcukce44dpb4bmv4edj(a)4ax.com>, Mark <i(a)dontgetlotsofspamanymore.invalid> wrote: > Hi, > > I am using a BufferedReader to read character data in from a file. It > works but it's incredibly slow. (The file consists of a number of > separate messages, each separated by a special character. Each > message must be read into a separate string.) > > I use the following code (exception handling removed for brevity): > > String text = new String(""); > BufferedReader in = null; > in = new BufferedReader(new InputStreamReader(new > FileInputStream(_msgFile))); > int c; > while ((c = in.read()) != -1) { > if (c == '@') { > _msgList.add(text); > text = ""; > } else { > text += (char)c; > } > } > if (text.length() > 0) { > _msgList.add(text); > } String text = new String(""); * RTFM * -- I won't see Google Groups replies because I must filter them as spam
From: Roedy Green on 23 Jan 2010 01:24
On Fri, 22 Jan 2010 06:19:31 -0800 (PST), GK <g.krost(a)gmail.com> wrote, quoted or indirectly quoted someone who said : > >@Roedy: you suggesting using StringBuilder which is never wrong, but >AFAIK later java releases do that optimization during compile. I don't think either Javac or HotSpot is clever about an initial estimate for the StringBuilder size. When you do it explicitly you can control the estimates. With optimal estimates, one program I wrote speeded up 10%. I now use FastCat which requires an estimate of total number of chunks (much easier to estimate) rather than the size of the final String. Most of the time I have the estimate bang on. If your estimate is too small, it will have to take time out to double in size over and over. If it is too big, you waste RAM and cause more frequent GCs. I talked to the Jet people about various optimisations. They figured most programs don't do enough concatenation to make the game worth the candle. It seem to me that most server side code is nothing BUT concatenation, or the equivalent, writing to some sort of RAM-resident stream buffer. -- Roedy Green Canadian Mind Products http://mindprod.com If we have learned one thing from the history of invention and discovery, it is that, in the long run � and often in the short one � the most daring prophecies seem laughably conservative. ~ Arthur C. Clarke (born: 1917-12-16 died: 2008-03-19 at age: 90) |