wood burning stoves 2.0*
The moose likes Java in General and the fly likes BufferedReader.readLine() skips lines Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "BufferedReader.readLine() skips lines" Watch "BufferedReader.readLine() skips lines" New topic
Author

BufferedReader.readLine() skips lines

Oliver Moore
Ranch Hand

Joined: Mar 04, 2003
Posts: 44
Hi All,

I'm reading a file using BufferedReader.readline(). I've noticed that the formatting of the file you're trying to read has to be spaced by carrage returns!! Is this correct behaviour?

My Code is:



If my text file is formatted as follows, only test2 and null will be output.

Start Of File
test1
test2
test3
EOF

However, if I format it as follows, test1, test2 and test3 will be output.

Start Of File
*carriage return
test1
*carriage return
test2
*carriage return
test3
EOF

Utilmately, this can be solved by carefully formatting my input first, but can anyone explain if it's an inherant Java problem or my code.

Thanks!!


Regards,<p>Ols
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Like, why are you reading the lines of your file twice in your while loop?


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Oliver Moore
Ranch Hand

Joined: Mar 04, 2003
Posts: 44
ah... that's the exact problem.... thanks...

First time I've played with IO...
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Don't worry, done it myself once
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BufferedReader.readLine() skips lines
 
Similar Threads
NEWBIE NEEDS HELP
Runtime.getRuntime() help plzzzzzzzz
Reading and displaying Strings from a file
Not Reading Entire File
Problem reading a file