I'm curious as to what opinions people might have on this. If I'm writing a program that reads in a file line-by-line and processes each one, I'm used to doing it the old K&R C-style:
reader = new BufferedReader(new FileReader(filename));
String nextLine = null;
while((nextLine = reader.readLine()) != null) {
// Do something
}
Every so often I run my code through tools like PMD and FindBugs to see what advice they might have. And it seems as though they really don't like this construct. So, I'm wondering, is there a best-practice way to do this? Something a bit cleaner that people like to use?