Following to some forums answers I\'m using this:
while (fileReader.nextLine() != null) {
String line = fileReader.nextLine();
System.out
The others told you enough about your issue with multiple calls of readLine()
.
I just wanted to leave sth about code style:
While you see this line =
assignement and != null
check together in one while condition in most examples (like @gotomanners example here) I prefer using a for
for it.
It is much more readable in my opinion ...
for (String line = in.readLine(); line != null; line = in.readLine()) {
...
}
Another nice way to write it you see in @TheCapn's example. But when you write it that way you easily see that's what a for-loop is made for.
I do not like assignments scrambled with conditions in one line. It is bad style in my opinion. But because it is so MUCH popular for that special case here to do it that way I would not consider it really bad style. (But cannot understand who established this bad style to become that popular.)