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.
Example:
In JDK7, finally is no longer required. The file will be closed automatically after try block.
Following is the example of the updated try block
try(open file or resource here){
//...
}
//after try block, file will close automatically.
Example:
In JDK7, finally is no longer required. The file will be closed automatically after try block.
No comments:
Post a Comment