Team LiB
Previous Section Next Section

Java 1.1readable closeable

This abstract class is the superclass of all character input streams. It is an analog to InputStream, which is the superclass of all byte input streams. Reader defines the basic methods that all character output streams provide. read( ) returns a single character or an array (or subarray) of characters, blocking if necessary; it returns -1 if the end of the stream has been reached. ready( ) returns true if there are characters available for reading. If ready( ) returns TRue, the next call to read( ) is guaranteed not to block. close( ) closes the character input stream. skip( ) skips a specified number of characters in the input stream. If markSupported( ) returns true, mark( ) marks a position in the stream and, if necessary, creates a look-ahead buffer of the specified size. Future calls to reset( ) restore the stream to the marked position if they occur within the specified look-ahead limit. Note that not all stream types support this mark-and-reset functionality. To create a subclass of Reader, you need only implement the three-argument version of read( ) and the close( ) method. Most subclasses implement additional methods, however.

Figure 9-54.

public abstract class Reader implements Closeable, Readable {
// Protected Constructors
     protected Reader( );  
     protected Reader(Object lock);  
// Public Instance Methods
     public abstract void close( ) throws IOException; Implements:Closeable
     public void mark(int readAheadLimit) throws IOException;  
     public boolean markSupported( );                                     constant
     public int read( ) throws IOException;  
     public int read(char[ ] cbuf) throws IOException;  
     public abstract int read(char[ ] cbuf, int off, int len) throws IOException;  
     public boolean ready( ) throws IOException;                          constant
     public void reset( ) throws IOException;  
     public long skip(long n) throws IOException;  
// Methods Implementing Closeable
     public abstract void close( ) throws IOException;  
// Methods Implementing Readable
5.0  public int read(java.nio.CharBuffer target) throws IOException;  
// Protected Instance Fields
     protected Object lock;  


BufferedReader, CharArrayReader, FilterReader, InputStreamReader, PipedReader, StringReader

Passed To

BufferedReader.BufferedReader( ), FilterReader.FilterReader( ), LineNumberReader.LineNumberReader( ), PushbackReader.PushbackReader( ), StreamTokenizer.StreamTokenizer( ),{setReader( ), StreamSource( )}, org.xml.sax.InputSource.{InputSource( ), setCharacterStream( )}

Returned By

java.nio.channels.Channels.newReader( ), ), org.xml.sax.InputSource.getCharacterStream( )

Type Of

    Team LiB
    Previous Section Next Section