You use a reader almost exactly as you use an input stream. Rather
than reading bytes, you read characters. The basic
read() method reads a specified number of
characters from the underlying input stream into an array starting at
a given offset:
public abstract int read(char buffer, int offset, int length) throws IOException
read() method returns the number of
characters actually read. As with input streams reading bytes, there
may not be as many characters available as you requested. Also like
read() method of an input stream, it returns
-1 when it detects the end of the data.
read() method is abstract. Concrete
subclasses that read bytes from some source must override this
IOException may be thrown if the
read() method throws an
IOException or an encoding error is detected.
You can also fill an array with characters using this method:
public int read(char buffer) throws IOException
This is equivalent to invoking
buffer.length). Thus, it
also returns the number of characters read and throws an
IOException when the underlying stream throws an
IOException or when an encoding error is detected.
The following method reads a single character and returns it:
public int read() throws IOException
int is returned, this
int is always between
and 65,535 and may be cast to a
losing information. All three
read() methods block until some input is available, an I/O error occurs, or the end ...