The code in your post looks like Java 6 code. Can you post a link to the webpage containing that code? Note that Oracle's Java tutorials stopped being updated since Java 8. Nonetheless, I believe that, at least, the code would use "try-with-resources".