public class NonBlockingReaderImpl extends NonBlockingReader
VERY IMPORTANT NOTES
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.
|
boolean |
ready() |
void |
shutdown()
Shuts down the thread that is handling blocking I/O.
|
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
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 NonBlockingReaderpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class ReaderIOExceptionpublic boolean ready()
throws IOException
ready in class ReaderIOExceptionprotected int read(long timeout,
boolean isPeek)
throws IOException
read in class NonBlockingReadertimeout - The amount of time to wait for the characterisPeek - trueif the character read must not be consumedIOException - if anything wrong happenspublic void clear()
throws IOException
IOExceptionCopyright © 2018. All rights reserved.