More idiomatic code, using new Java 7 try-with-resources statement