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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 36575
    
  16
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: 57

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
EJB 3.1 Cookbook
Java 7 New Features Cookbook
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: try-with-resources
 
Similar Threads
Struts
checkbox validation
How do I refer to a text data file so a .jar can find it?
what is your favorite java 7 feature?
Placing a pdf under WEB-INF/classes and accessing it through relative url