Methods Summary |
---|
public void | close()Closes the underlying input stream and replaces the reference to it
with a {@link ClosedInputStream} instance.
This method is automatically called by the read methods when the end
of input has been reached.
Note that it is safe to call this method any number of times. The original
underlying input stream is closed and discarded only once when this
method is first called.
in.close();
in = new ClosedInputStream();
|
protected void | finalize()Ensures that the stream is closed before it gets garbage-collected.
As mentioned in {@link #close()}, this is a no-op if the stream has
already been closed.
close();
super.finalize();
|
public int | read()Reads and returns a single byte from the underlying input stream.
If the underlying stream returns -1, the {@link #close()} method is
called to automatically close and discard the stream.
int n = in.read();
if (n == -1) {
close();
}
return n;
|
public int | read(byte[] b)Reads and returns bytes from the underlying input stream to the given
buffer. If the underlying stream returns -1, the {@link #close()} method
i called to automatically close and discard the stream.
int n = in.read(b);
if (n == -1) {
close();
}
return n;
|
public int | read(byte[] b, int off, int len)Reads and returns bytes from the underlying input stream to the given
buffer. If the underlying stream returns -1, the {@link #close()} method
i called to automatically close and discard the stream.
int n = in.read(b, off, len);
if (n == -1) {
close();
}
return n;
|