Java Reference
In-Depth Information
turned. If no bytes are read because the end of the stream
was found, the value 1 is returned. If
count
is zero then no
bytes are read and zero is returned. This method blocks until
input is available, the end of stream is found, or an excep-
tion is thrown. If the first byte cannot be read for any reason
other than reaching the end of the streamin particular, if the
stream has already been closedan
IOException
is thrown. Once
a byte has been read, any failure that occurs while trying to
read subsequent bytes is not reported with an exception but
is treated as encountering the end of the streamthe method
completes normally and returns the number of bytes read be-
fore the failure occurred.
public int
read(byte[] buf)
throws IOException
Equivalent to
read(buf,0, buf.length)
.
public long
skip(long count)
throws IOException
Skips as many as
count
bytes of input or until the end of the
stream is found. Returns the actual number of bytes skipped.
If
count
is negative, no bytes are skipped.
public int
available()
tHRows IOException
Returns the number of bytes that can be read (or skipped
over) without blocking. The default implementation returns
zero.
public void
close()
tHRows IOException
Closes the input stream. This method should be invoked to re-
lease any resources (such as file descriptors) associated with
the stream. Once a stream has been closed, further opera-
tions on the stream will throw an
IOException
. Closing a previ-
ously closed stream has no effect. The default implementation
of
close
does nothing.