Team LiB
Previous Section Next Section

PushbackReaderjava.io

Java 1.1readable closeable

This class is a character input stream that uses another input stream as its input source and adds the ability to push characters back onto the stream. This feature is often useful when writing parsers. When you create a PushbackReader stream, you specify the stream to be read from and, optionally, the size of the pushback buffer (i.e., the number of characters that may be pushed back onto the stream or unread). If you do not specify a size for this buffer, the default size is one character. PushbackReader inherits or overrides all standard Reader methods and adds three unread( ) methods that push a single character, an array of characters, or a portion of an array of characters back onto the stream. This class is the character stream analog of PushbackInputStream.

Figure 9-52. java.io.PushbackReader


public class PushbackReader extends FilterReader {
// Public Constructors
     public PushbackReader(Reader in);  
     public PushbackReader(Reader in, int size);  
// Public Instance Methods
     public void unread(int c) throws IOException;  
     public void unread(char[ ] cbuf) throws IOException;  
     public void unread(char[ ] cbuf, int off, int len) throws IOException;  
// Public Methods Overriding FilterReader
     public void close( ) throws IOException;  
1.2  public void mark(int readAheadLimit) throws IOException;  
     public boolean markSupported( );                                     constant
     public int read( ) throws IOException;  
     public int read(char[ ] cbuf, int off, int len) throws IOException;  
     public boolean ready( ) throws IOException;  
1.2  public void reset( ) throws IOException;  
1.4  public long skip(long n) throws IOException;  
}

    Team LiB
    Previous Section Next Section