The methods of the java.io.Reader
class
are deliberately similar to the methods of the java.io.InputStream
class.
The basic read()
method reads a single character
(which may may take between one and four bytes depending on the character set)
and returns the character as an int between 0 and 65535.
It returns -1 if the end of stream is seen.
public int read() throws IOException
You can also read many characters into an array of chars.
public int read(char[] text) throws IOException
public abstract int read(char[] text, int offset, int length)
throws IOException
All the read()
methods block until some input is
available, an I/O error occurs, or the end of the stream is reached.
You can skip a certain number of characters.
public long skip(long n) throws IOException
The ready()
method returns true if the reader is
ready to be read from, false if it isn't.
public boolean ready() throws IOException
Readers may or may not support marking and resetting, like input streams.
public boolean markSupported()
public void mark(int readAheadLimit) throws IOException
public void reset() throws IOException
Finally the close()
method closes the
Reader
and releases any resources associated with
it.
public abstract void close() throws IOException