aspose file tools*
The moose likes Features new in Java 7 and the fly likes try-with-resources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Features new in Java 7
Bookmark "try-with-resources" Watch "try-with-resources" New topic
Author

try-with-resources

Rick Goff
Ranch Hand

Joined: Nov 14, 2006
Posts: 54

What are the best practices emerging for implementation/refactoring related to try-with-resources?


OCPJP 6
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
If you have something predating try-with-resources, you should be instantiating the IfItAintBrokeDontFixIt class
Richard Reese
author
Ranch Hand

Joined: Jul 13, 2011
Posts: 84
    
    5

I concur with Ritchie's answer. However, for the applications that uses try block and are in need of re-writing the try-with-resources block is the way to go. NetBeans 7.1.1 apparently has a tool that will assist in the conversion of an older application to Java 7, including try-with-resources conversion. I haven't used it but it is discussed at http://netbeans.org/kb/docs/java/editor-inspect-transform.html


Richard Reese
Java 8 New Features: A Practical Heads-Up Guide
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: try-with-resources