| Author |
Reading a text file using FileReader & BufferedReader : Unexpected output !
|
Rahul Sudip Bose
Ranch Hand
Joined: Jan 21, 2011
Posts: 637
|
|
the program below compiles properly. Its supposed to "print" the below source code saved inside "mytxt.txt" . But i get only some parts of the text in output.
PS : how do i upload the screen shot of the console output from my pc ?
|
SCJP 6. Learning more now.
|
 |
Stephan van Hulst
Bartender
Joined: Sep 20, 2010
Posts: 3044
|
|
|
You are reading from your file twice at each iteration, but you are only storing half of the lines in data.
|
 |
Tom Reilly
Rancher
Joined: Jun 01, 2010
Posts: 618
|
|
|
I surmise that it is only printing the even numbered lines in your file. That is because your while statement is reading a line and then you read another line in the while loop. And you only print the line that was read in the loop. Try:
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Reading a text file using FileReader & BufferedReader : Unexpected output !
|
|
|