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.

java.io.CharArrayReader

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;  
}

Get Java in a Nutshell, 5th Edition 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.