Java Reference
In-Depth Information
read because the end of the stream was found, 1 is returned.
This is equivalent to reading into an array that has the same
length as the buffer has available capacity, and then copying
the array into the buffer. This method is defined in the
java.lang.Readable
interface, and has no counterpart in
In-
putStream
.
public long
skip(long count)
throws IOException
Skips as many as
count
characters of input or until the end of
the stream is found. Returns the actual number of characters
skipped. The value of
count
must not be negative.
public boolean
ready()
tHRows IOException
Returns
TRue
if the stream is ready to read; that is, there is
at least one character available to be read. Note that a return
value of
false
does not guarantee that the next invocation of
read
will block because data could have become available by
the time the invocation occurs.
public abstract void
close()
throws IOException
Closes the stream. This method should be invoked to release
any resources (such as file descriptors) associated with the
stream. Once a stream has been closed, further operations
on the stream will throw an
IOException
. Closing a previously
closed stream has no effect.
The implementation of
Reader
requires that a subclass provide an imple-
mentation of both the
read
method that reads into a char array, and the
close
method. Many subclasses will be able to improve performance if
they also override some of the other methods.
There are a number of differences between
Reader
and
InputStream
. With
Reader
the fundamental reading method reads into a char array and the
other read methods are defined in terms of this method. In contrast