Switched to try-with-resources where applicable.

- Further removes compatibility with Java 6