Closeable
, AutoCloseable
, Readable
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 | Description |
---|---|---|
static int |
READ_EXPIRED |
EOF
Constructor | Description |
---|---|
NonBlockingReaderImpl(String name,
Reader in) |
Creates a
NonBlockingReader out of a normal blocking
reader. |
Modifier and Type | Method | 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) |
|
boolean |
ready() |
|
void |
shutdown() |
Shuts down the thread that is handling blocking I/O.
|
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
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 AutoCloseable
close
in interface Closeable
close
in class Reader
IOException
public boolean ready() throws IOException
ready
in class Reader
IOException
public int readBuffered(char[] b) 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
Copyright © 2020. All rights reserved.