Reputation: 2406
I create a BufferedInputStream from an InputStream. I can close the BufferedInputStream by calling its close() method. Should I also close the InputStream from which it was created, or does that happen sutomatically?
Upvotes: 1
Views: 457
Reputation: 1041
Closing BufferedInputStream
is sufficient since it closes the underlying stream as well.
This can also be seen in the implementation: https://github.com/openjdk/jdk/blob/9a7209ef346e4f78b6153e998ecdfac72edc5580/src/java.base/share/classes/java/io/BufferedInputStream.java#L482
Upvotes: 2