Why doesn’t my BufferedReader that reads while readLine!=null work? [duplicate]

For each (successful) iteration of the loop, you’re reading two lines – one in the while condition, and then another one in the loop’s body. The line read in the loop’s condition is discarded, and thus you see the missing line.

Instead, you can store the line in a variable in the loop’s condition, and then use it in the loop’s body:

String line;
while ((line = bufferedReader.readLine()) != null) {

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top