You may want to use Java 7 try-with-resources.

(shameless plug: http://www.oracle.com/technetwork/articles/java/trywithresources-401775.html)