Name
Reader
Synopsis
Reader
is an abstract class that defines the methods
implemented by subclasses that provide character input. A
Reader
differs from an InputStream
in
that it works in terms of 16-bit Unicode characters rather than 8-bit bytes.
An 8-bit InputStream
can be converted to a sequence of
Unicode characters by wrapping it with an instance of the
InputStreamReader
class, which is the only concrete
subclass of Reader
provided in the CLDC
java.io
package.
Most of the methods provided by Reader
are the same as
those available from InputStream
, except that the
fundamental unit of transfer is a char
rather than a
byte
. The read()
methods copy data from
the data source into a character array, or return a single character held in
the least significant 16 bits of an int
. The
skip()
method skips over the given number of
char
s in the input source, or until end-of-file
is reached. The mark()
, reset()
and
markSupported()
methods behave the same as an
InputStream
, except that the limit value passed to the
mark()
method is expressed in characters, not bytes.
Reader
does not have an available()
method that returns the amount of data waiting to be read without blocking.
Instead, it has a ready()
method that simply returns
true
if there is some data to be read, and
false
if there is not.
public abstract class Reader { // Protected Constructors protected Reader(); protected Reader( Object lock); // Public Instance Methods public abstract void close() throws IOException; public void ...
Get J2ME in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.