public class NonBlockingReader extends Reader implements Runnable
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 |
Constructor and Description |
---|
NonBlockingReader(String name,
Reader in)
Creates a
NonBlockingReader out of a normal blocking
reader. |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
close() |
int |
peek(long timeout)
Peeks to see if there is a byte waiting in the input stream without
actually consuming the byte.
|
int |
read() |
int |
read(char[] b,
int off,
int len)
This version of read() is very specific to jline's purposes, it
will always always return a single byte at a time, rather than filling
the entire buffer.
|
int |
read(long timeout)
Attempts to read a character from the input stream for a specific
period of time.
|
boolean |
ready() |
void |
run() |
void |
shutdown()
Shuts down the thread that is handling blocking I/O.
|
public static final int READ_EXPIRED
public NonBlockingReader(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.in
- The reader to wrappublic void shutdown()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Reader
IOException
public int read() throws IOException
read
in class Reader
IOException
public int peek(long timeout) throws IOException
timeout
- The amount of time to wait, 0 == foreverIOException
public int read(long timeout) throws IOException
timeout
- The amount of time to wait for the characterIOException
public boolean ready() throws IOException
ready
in class Reader
IOException
public int read(char[] b, int off, int len) throws IOException
read
in class Reader
IOException
public void clear() throws IOException
IOException
Copyright © 2019. All rights reserved.