FileInputStream fstream = new FileInputStream(someFile.getPath());
DataInputStream in = new DataInputStream(fstream);
If i call in.close()
, will it also close fstream
? My code is giving GC Exception as follows:
java.lang.OutOfMemoryError: GC overhead limit exceeded
Yes, DataInputStream.close()
also closes your FileInputStream
.
This is because DataInputStream
inherits FilterInputStream
which has the following implementation of the close()
method:
public void close() throws IOException {
in.close();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With