10 March 2017

Java | try with resources statement

Since Java 1.7 you can declare all resources that can be closed. e.g BufferedReader right after the try statement. With this feature, all resources will be closed and errors will be caught automatically. Before Java 1.7 you'll have to close all resources manually. like this:
managing resources before java 1.7
Since Java 1.7 this is simplified to this:
managing resources after java 1.7

No comments:

Post a Comment