Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Input reading best practices

jeisenJun 25 2009 — edited Jun 26 2009
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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 24 2009
Added on Jun 25 2009
12 comments
247 views