java.io.PushbackReader
java.io.FilterReader
None
None
New as of JDK 1.1
The PushbackReader class represents a character stream that allows data to be pushed back into the stream. In other words, after data has been read from a PushbackReader, it can be pushed back into the stream so that it can be reread. This functionality is useful for implementing things like parsers that need to read data and then return it to the input stream. PushbackReader is the character-oriented equivalent of PushbackInputStream.
public class java.io.PushbackReader extends java.io.FilterReader { // Constructors public PushbackReader(Reader in); public PushbackReader(Reader in, int size); // Instance Methods public void close(); public boolean markSupported(); public int read(); public int read(char[] cbuf, int off, int len); public boolean ready(); public void unread(int c); public void unread(char[] cbuf); public void unread(char[] cbuf, int off, int len); }
The reader to wrap.
This constructor creates a PushbackReader that reads from the given Reader, using a pushback buffer with the default size of one byte.
The reader to wrap.
The size of the pushback buffer.
This constructor creates a PushbackReader that reads from the given Reader, using a pushback buffer of the given size.
If any kind of I/O error occurs.
FilterReader.close()
This method closes the reader and releases the system resources that are associated with it.
The boolean value false.
FilterReader.markSupported()
This method returns false to indicate that this class does not support mark() and reset().
The next character of data or -1 if the end of the stream is encountered.
If any kind of I/O error occurs.
FilterReader.read()
This method reads a character of data. If there is any data in the pushback buffer, the method returns the next character in the pushback buffer. Otherwise, it calls the read() method of the underlying stream. The method blocks until the character is read, the end of the stream is encountered, or an exception is thrown.
An array of characters to be filled from the stream.
An offset into the array.
The number of characters to read.
The actual number of characters read or -1 if the end of the stream is encountered immediately.
If any kind of I/O error occurs.
FilterReader.read(char[], int, int)
This method copies characters from the stream into the given array cbuf, starting at index off and continuing for len characters. If the array can be populated solely from the pushback buffer, the method returns immediately. Otherwise, the read(char[], int, int) method of the underlying stream is called to make up the difference. The method blocks until some data is available.
A boolean value that indicates whether the stream is ready to be read.
If the stream is closed.
FilterReader.ready()
If there is data in the pushback buffer, or if the underlying stream is ready, this method returns true. The underlying stream is ready if the next read() is guaranteed not to block.
The value to push back.
If the pushback buffer is full.
This method puts the given character into the pushback buffer.
An array of characters to push back.
If the pushback buffer is full.
This method puts all of the characters in the given array into the pushback buffer.
An array of characters to push back.
An offset into the array.
The number of characters to push back.
If the pushback buffer is full.
This method puts len characters from the given array, starting at offset off, into the pushback buffer.
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
equals(Object) |
Object |
finalize() |
Object |
getClass() |
Object |
hashCode() |
Object |
mark(int) |
FilterReader |
notify() |
Object |
notifyAll() |
Object |
read(char[]) |
FilterReader |
reset() |
FilterReader |
skip(long) |
FilterReader |
toString() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
FilterReader, IOException, Reader
This HTML Help has been published using the chm2web software. |