BTW: You ought to have been told, you can get potential problems if you open a file and don't close it. You have to put the close bit in a finally block; then even if there is an Exception, it is still executed.
But, the close() method might throw an Exception, so it has to be inside a try block as well.
The best answer is usually:-
That way you make absolutely sure that whatever file you opened is closed again.