Name
CharArrayReader
Synopsis
This
class is a character input stream that uses a character
array as the source of the
characters it returns. You create a
CharArrayReader by specifying the character array
(or portion of an array) it is to read from.
CharArrayReader defines the usual
Reader methods and supports the mark(
)
and reset( )
methods. Note that the character array you pass to the
CharArrayReader( ) constructor is not copied. This
means that changes you make to the elements of the array after you
create the input stream affect the values read from the array.
CharArrayReader is the character-array analog of
ByteArrayInputStream and is similar to
StringReader.
Figure 9-7. java.io.CharArrayReader
public class CharArrayReader extends Reader { // Public Constructors public CharArrayReader(char[ ] buf); public CharArrayReader(char[ ] buf, int offset, int length); // Public Methods Overriding Reader public void close( ); public void mark(int readAheadLimit) throws IOException; public boolean markSupported( ); constant public int read( ) throws IOException; public int read(char[ ] b, int off, int len) throws IOException; public boolean ready( ) throws IOException; public void reset( ) throws IOException; public long skip(long n) throws IOException; // Protected Instance Fields protected char[ ] buf; protected int count; protected int markedPos; protected int pos; }
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access