Reputation: 1211
When you call close()
method on an object reference for OutputStream/InputStream object, will the object reference be pointing to null? or Do we need to explicitly set it to null to make the object memory available for GC?
Upvotes: 0
Views: 403
Reputation: 19702
No. close()
will free some underlying resources and objects, but this object still exists.
Actually, close()
may not do anything, for example, in ByteArrayInputStream
/**
* Closing a <tt>ByteArrayInputStream</tt> has no effect. The methods in
* this class can be called after the stream has been closed without
* generating an <tt>IOException</tt>.
*/
public void close() throws IOException {
}
you can call close()
on it, and then still use it like nothing happens.
Upvotes: 1
Reputation: 3
There is no need to nullify stream, once stream is closed and goes out of scope, the stream is marked for Garbage collection automatically.
Upvotes: 0