Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 115
نمايش فراداده

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