I was wondering what is the best / suitable way to release file resources / descriptors.
Traditional code
BufferredInputStream stream = null try{ ---- stream = new BufferredInputStream(new FileInputStream()); ---- } finally{ if(stream != null){ stream.close() }
}
Whether the file descriptor will be released by closing BufferredInputStream.close its own or whether it needs the underlying stream(ie FileInputStream.close()) explicitly.
PS Javadoc for [FilterOutputStream.close] indicates that it also explicitly closes the underlying stream. But other threads don't seem to have this in the document.
[FilterOutputStream.close]: http://docs.oracle.com/javase/1.4.2/docs/api/java/io/FilterOutputStream.html
I ask for advice. Thanks in advance.
source share