Wednesday, February 12, 2014

Java 1.7 Update: Try-With-Resources

8:59 PM

Since JDK 1.7, a new "try-with-resources" approach is introduced. When a try block is end, it will close or release your opened file automatically.

Following is the example of the updated try block 

try(open file or resource here){


//after try block, file will close automatically.


In JDK7, finally is no longer required. The file will be closed automatically after try block.


Post a Comment


© 2014 DieHardTechy . All rights resevered. Designed by Diehardtechy