Name

PushbackReader

Synopsis

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.

java.io.PushbackReader

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

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.