public class NonBlockingInputStreamImpl extends NonBlockingInputStream
VERY IMPORTANT NOTES
NonBlockingInputStreamImpl.shutdown()
method must be called in order to shut down
the thread that handles blocking I/O.
EOF, READ_EXPIRED
Constructor and Description |
---|
NonBlockingInputStreamImpl(String name,
InputStream in)
Creates a
NonBlockingReader out of a normal blocking
reader. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
int |
read(long timeout,
boolean isPeek)
Attempts to read a byte from the input stream for a specific
period of time.
|
void |
shutdown()
Shuts down the thread that is handling blocking I/O.
|
peek, read, read, read, readBuffered, readBuffered, readBuffered
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
public NonBlockingInputStreamImpl(String name, InputStream 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
NonBlockingInputStreamImpl.shutdown()
method must be called in order to shut this thread down.name
- The stream namein
- The reader to wrappublic void shutdown()
shutdown
in class NonBlockingInputStream
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public int read(long timeout, boolean isPeek) throws IOException
read
in class NonBlockingInputStream
timeout
- The amount of time to wait for the characterisPeek
- true
if the byte read must not be consumedIOException
- if anything wrong happens