changed try-catch-finally to the new java 7 try-with-resources style