public class NonBlockingReaderImpl extends NonBlockingReader
VERY IMPORTANT NOTES
NonBlockingReaderImpl.shutdown()
method must be called in order to shut down
the thread that handles blocking I/O.
Modifier and Type | Field and Description |
---|---|
static int |
READ_EXPIRED |
EOF
Constructor and Description |
---|
NonBlockingReaderImpl(String name,
Reader in)
Creates a
NonBlockingReader out of a normal blocking
reader. |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
close() |
protected int |
read(long timeout,
boolean isPeek)
Attempts to read a character from the input stream for a specific
period of time.
|
int |
readBuffered(char[] b,
int off,
int len,
long timeout) |
boolean |
ready() |
void |
shutdown()
Shuts down the thread that is handling blocking I/O.
|
available, peek, read, read, read, readBuffered, readBuffered
mark, markSupported, nullReader, read, read, reset, skip, transferTo
public static final int READ_EXPIRED
public NonBlockingReaderImpl(String name, Reader in)
NonBlockingReader
out of a normal blocking
reader. Note that this call also spawn a separate thread to perform the
blocking I/O on behalf of the thread that is using this class. The
NonBlockingReaderImpl.shutdown()
method must be called in order to shut this thread down.name
- The reader namein
- The reader to wrappublic void shutdown()
shutdown
in class NonBlockingReader
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Reader
IOException
public boolean ready() throws IOException
ready
in class Reader
IOException
public int readBuffered(char[] b, int off, int len, long timeout) throws IOException
readBuffered
in class NonBlockingReader
IOException
protected int read(long timeout, boolean isPeek) throws IOException
read
in class NonBlockingReader
timeout
- The amount of time to wait for the characterisPeek
- true
if the character read must not be consumedIOException
- if anything wrong happenspublic void clear() throws IOException
IOException