• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

try-with-resources

 
Rick Goff
Ranch Hand
Posts: 54
Clojure Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the best practices emerging for implementation/refactoring related to try-with-resources?

 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have something predating try-with-resources, you should be instantiating the IfItAintBrokeDontFixIt class
 
Richard Reese
author
Ranch Hand
Posts: 84
5
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic