java.base have several opportunities to use the "try-with-resources" feature. Using this feature will help ensure that resources are closed properly, especially in case exceptions are thrown. A couple related cleanups in these files are also necessary.