Reputation: 845
As per the official documentation:
public void close() throws IOException
Closes this input stream and releases any system resources associated with the stream.
The close method of InputStream does nothing.
So does it do nothing or something?
Upvotes: 6
Views: 4420
Reputation: 23329
No it doesn't do anything, but InputStream
is an abstract
class where close
isn't abstract (it implements java.io.Closeable
), it has an empty body. Implementers of InputStream
can optionally override the method. FileInputStream
closes the file input stream and releases any system resources where ByteInputStream
does nothing.
Upvotes: 10
Reputation: 4233
As @Kayaman says, InputStream
is an abstract class and close
method is not implemented there. If your are curious you can see this link which sows you close method on java.io.FileInputStream
of openjdk version 8u40-b25, from GrepCode.
Upvotes: -1
Reputation: 73528
The close()
method of InputStream
does nothing. The close()
method of subclasses of InputStream
may do something.
Upvotes: 3