@NotThreadSafe public class NonBlockingStringReader extends Reader
StringReader.Reader uses the lock object internally only for
long skip(long n) and as this method is overwritten in here, the
lock is never used.StringReader| Constructor and Description |
|---|
NonBlockingStringReader(char[] aChars) |
NonBlockingStringReader(char[] aChars,
int nOfs,
int nLen) |
NonBlockingStringReader(String sStr)
Creates a new string reader.
|
NonBlockingStringReader(String sStr,
int nOfs,
int nLen) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the stream and releases any system resources associated with it.
|
void |
mark(int nReadAheadLimit)
Marks the present position in the stream.
|
boolean |
markSupported()
Tells whether this stream supports the mark() operation, which it does.
|
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 to the most recent mark, or to the beginning of the
string if it has never been marked.
|
long |
skip(long nCharsToSkip)
Skips the specified number of characters in the stream.
|
public NonBlockingStringReader(@Nonnull char[] aChars)
public NonBlockingStringReader(@Nonnull char[] aChars, @Nonnegative int nOfs, @Nonnegative int nLen)
public NonBlockingStringReader(@Nonnull String sStr)
sStr - String providing the character stream. May not be null.public NonBlockingStringReader(@Nonnull String sStr, @Nonnegative int nOfs, @Nonnegative int nLen)
@CheckForSigned public int read() throws IOException
read in class ReaderIOException - If an I/O error occurs@CheckForSigned public int read(@Nonnull char[] aBuf, @Nonnegative int nOfs, @Nonnegative int nLen) throws IOException
read in class ReaderaBuf - Destination buffernOfs - Offset at which to start writing charactersnLen - Maximum number of characters to readIOException - If an I/O error occurspublic long skip(long nCharsToSkip)
throws IOException
skip in class ReadernCharsToSkip - The parameter may be negative, even though the skip
method of the Reader superclass throws an exception in this
case. Negative values of the parameter cause the stream to skip
backwards. Negative return values indicate a skip backwards. It is
not possible to skip backwards past the beginning of the string.IOException - If an I/O error occurspublic boolean ready()
throws IOException
ready in class Readertrue if the next read() is guaranteed not to block for
inputIOException - If the stream is closedpublic boolean markSupported()
markSupported in class Readertruepublic void mark(int nReadAheadLimit)
throws IOException
mark in class ReadernReadAheadLimit - Limit on the number of characters that may be read while still
preserving the mark. Because the stream's input comes from a string,
there is no actual limit, so this argument must not be negative, but
is otherwise ignored.IllegalArgumentException - If readAheadLimit is < 0IOException - If an I/O error occurspublic void reset()
throws IOException
reset in class ReaderIOException - If an I/O error occurspublic void close()
Copyright © 2014–2020 Philip Helger. All rights reserved.