public class PushbackReader extends FilterReader
in
Constructor and Description |
---|
PushbackReader(Reader in)
Creates a new pushback reader with a one-character pushback buffer.
|
PushbackReader(Reader in,
int size)
Creates a new pushback reader with a pushback buffer of the given size.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the stream and releases any system resources associated with
it.
|
void |
mark(int readAheadLimit)
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.
|
int |
read(char[] cbuf,
int off,
int len)
Reads characters into a portion of an array.
|
boolean |
ready()
Tells whether this stream is ready to be read.
|
void |
reset()
Resets the stream.
|
long |
skip(long n)
Skips characters.
|
void |
unread(char[] cbuf)
Pushes back an array of characters by copying it to the front of the
pushback buffer.
|
void |
unread(char[] cbuf,
int off,
int len)
Pushes back a portion of an array of characters by copying it to the
front of the pushback buffer.
|
void |
unread(int c)
Pushes back a single character by copying it to the front of the
pushback buffer.
|
public PushbackReader(Reader in, int size)
IllegalArgumentException
- if size <= 0
in
- The reader from which characters will be readsize
- The size of the pushback bufferpublic 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 int read(char[] cbuf, int off, int len) throws IOException
read
in class FilterReader
IOException
- If an I/O error occurscbuf
- Destination bufferoff
- Offset at which to start writing characterslen
- Maximum number of characters to readpublic void unread(int c) throws IOException
(char)c
.IOException
- If the pushback buffer is full,
or if some other I/O error occursc
- The int value representing a character to be pushed backpublic 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.IOException
- If there is insufficient room in the pushback
buffer, or if some other I/O error occurscbuf
- Character arrayoff
- Offset of first character to push backlen
- Number of characters to push backpublic void unread(char[] cbuf) throws IOException
cbuf[0]
, the character after that
will have the value cbuf[1]
, and so forth.IOException
- If there is insufficient room in the pushback
buffer, or if some other I/O error occurscbuf
- Character array to push backpublic 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
IOException
- Always, since mark is not supportedreadAheadLimit
- 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.public 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 Closeable
close
in interface AutoCloseable
close
in class FilterReader
IOException
- If an I/O error occurspublic long skip(long n) throws IOException
skip
in class FilterReader
IllegalArgumentException
- If n
is negative.IOException
- If an I/O error occursn
- The number of characters to skipaicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2019 aicas GmbH. All Rights Reserved.