public class NonBlockingPushbackReader extends FilterReader
PushbackReader.PushbackReaderin| Constructor and Description |
|---|
NonBlockingPushbackReader(Reader aReader)
Creates a new pushback reader with a one-character pushback buffer.
|
NonBlockingPushbackReader(Reader aReader,
int nSize)
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.
|
int |
getUnreadCount() |
boolean |
hasUnreadChars() |
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[] aBuf,
int nOfs,
int nLen)
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 nSkip)
Skips characters.
|
void |
unread(char[] aBuf)
Pushes back an array of characters by copying it to the front of the
pushback buffer.
|
void |
unread(char[] aBuf,
int nOfs,
int nLen)
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 NonBlockingPushbackReader(@Nonnull Reader aReader, @Nonnegative int nSize)
aReader - The reader from which characters will be readnSize - The size of the pushback bufferIllegalArgumentException - if size is ≤ 0@Nonnegative public int getUnreadCount()
public boolean hasUnreadChars()
true if at least one "unread" char is present.public int read()
throws IOException
read in class FilterReaderIOException - If an I/O error occurspublic int read(@Nonnull char[] aBuf, @Nonnegative int nOfs, @Nonnegative int nLen) throws IOException
read in class FilterReaderaBuf - Destination buffernOfs - Offset at which to start writing charactersnLen - Maximum number of characters to readIOException - 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(@Nonnull char[] aBuf, @Nonnegative int nOfs, @Nonnegative int nLen) throws IOException
cbuf[off], the character after that
will have the value cbuf[off+1], and so forth.aBuf - Character arraynOfs - Offset of first character to push backnLen - 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(@Nonnull char[] aBuf) throws IOException
cbuf[0], the character after that will
have the value cbuf[1], and so forth.aBuf - 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 FilterReaderIOException - If an I/O error occurspublic void mark(int readAheadLimit)
throws IOException
mark for class
PushbackReader always throws an exception.mark in class FilterReaderIOException - Always, since mark is not supportedpublic void reset()
throws IOException
reset method of
PushbackReader always throws an exception.reset in class FilterReaderIOException - Always, since reset is not supportedpublic boolean markSupported()
markSupported in class FilterReaderpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class FilterReaderIOException - If an I/O error occurspublic long skip(long nSkip)
throws IOException
skip in class FilterReadernSkip - The number of characters to skip. Must be ≥ 0.IllegalArgumentException - If n is negative.IOException - If an I/O error occursCopyright © 2014–2017 Philip Helger. All rights reserved.