wood burning stoves 2.0*
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


Rick Goff
Ranch Hand

Joined: Nov 14, 2006
Posts: 54

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

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38007
If you have something predating try-with-resources, you should be instantiating the IfItAintBrokeDontFixIt class
Richard Reese
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
How do I refer to a text data file so a .jar can find it?
checkbox validation
what is your favorite java 7 feature?
Placing a pdf under WEB-INF/classes and accessing it through relative url