I'm still learning Java, and I need help to understand why this code is wrong:
BufferedReader infile = new BufferedReader(new FileReader(file));
String regel = infile.readLine();
while (regel != null) {
regel = infile.readLine();
}
infile.close();
I really don't see the problem, but Eclipse continues to report that there is a resource leak, and this infile is not closed.
(another detail, this code is in the try block, but I left it to stay simple)
source
share