Closeable, AutoCloseable, Readable
public class PushbackReader extends FilterReader
in
| Constructor | Description | 
|---|---|
| PushbackReader | Creates a new pushback reader with a one-character pushback buffer. | 
| PushbackReader | Creates a new pushback reader with a pushback buffer of the given size. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| void | close() | Closes the stream and releases any system resources associated with it. | 
| void | mark | Marks the present position in the stream. | 
| boolean | markSupported() | Tells whether this stream supports the mark() operation, which it does not. | 
| int | read() | Reads a single character. | 
| boolean | ready() | Tells whether this stream is ready to be read. | 
| void | reset() | Resets the stream. | 
| void | unread | Pushes back an array of characters by copying it to the front of the pushback buffer. | 
| void | unread | Pushes back a portion of an array of characters by copying it to the front of the pushback buffer. | 
| void | unread | Pushes back a single character by copying it to the front of the pushback buffer. | 
read, skip
nullReader, read, read, transferTo
public PushbackReader(Reader in, int size)
in - The reader from which characters will be readsize - The size of the pushback bufferIllegalArgumentException - if size <= 0
public PushbackReader(Reader in)
in - The reader from which characters will be readpublic int read() throws IOException
read in class FilterReader
IOException - If an I/O error occurspublic void unread(int c) throws IOException
(char)c.c - The int value representing a character to be pushed backIOException - If the pushback buffer is full, or if some other I/O error occurspublic void unread(char[] cbuf, int off, int len) throws IOException
cbuf[off], the character after that will have the value cbuf[off+1], and so forth.cbuf - Character arrayoff - Offset of first character to push backlen - Number of characters to push backIOException - If there is insufficient room in the pushback buffer, or if some other I/O error occurspublic void unread(char[] cbuf) throws IOException
cbuf[0], the character after that will have the value cbuf[1], and so forth.cbuf - Character array to push backIOException - If there is insufficient room in the pushback buffer, or if some other I/O error occurspublic boolean ready() throws IOException
ready in class FilterReader
IOException - If an I/O error occurspublic void mark(int readAheadLimit) throws IOException
mark for class PushbackReader always throws an exception.mark in class FilterReader
readAheadLimit - Limit on the number of characters that may be read while still preserving the mark. After reading this many characters, attempting to reset the stream may fail.IOException - Always, since mark is not supportedpublic void reset() throws IOException
reset method of PushbackReader always throws an exception.reset in class FilterReader
IOException - Always, since reset is not supportedpublic boolean markSupported()
markSupported in class FilterReader
public void close() throws IOException
close in interface AutoCloseable
close in interface Closeable
close in class Reader
IOException - If an I/O error occurs
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/PushbackReader.html