Package org.jline.utils
Class NonBlocking.NonBlockingInputStreamReader
java.lang.Object
java.io.Reader
org.jline.utils.NonBlockingReader
org.jline.utils.NonBlocking.NonBlockingInputStreamReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
- Enclosing class:
- NonBlocking
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteBuffer
private final CharBuffer
private final CharsetDecoder
private final NonBlockingInputStream
Fields inherited from class org.jline.utils.NonBlockingReader
EOF, READ_EXPIRED
-
Constructor Summary
ConstructorsConstructorDescriptionNonBlockingInputStreamReader
(NonBlockingInputStream inputStream, Charset encoding) NonBlockingInputStreamReader
(NonBlockingInputStream input, CharsetDecoder decoder) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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) void
shutdown()
Shuts down the thread that is handling blocking I/O.Methods inherited from class org.jline.utils.NonBlockingReader
available, peek, read, read, read, readBuffered, readBuffered
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, ready, reset, skip, transferTo
-
Field Details
-
input
-
decoder
-
bytes
-
chars
-
-
Constructor Details
-
NonBlockingInputStreamReader
-
NonBlockingInputStreamReader
-
-
Method Details
-
read
Description copied from class:NonBlockingReader
Attempts to read a character from the input stream for a specific period of time.- Specified by:
read
in classNonBlockingReader
- Parameters:
timeout
- The amount of time to wait for the characterisPeek
-true
if the character read must not be consumed- Returns:
- The character read, -1 if EOF is reached, or -2 if the read timed out.
- Throws:
IOException
- if anything wrong happens
-
readBuffered
- Specified by:
readBuffered
in classNonBlockingReader
- Throws:
IOException
-
shutdown
public void shutdown()Description copied from class:NonBlockingReader
Shuts down the thread that is handling blocking I/O. Note that if the thread is currently blocked waiting for I/O it will not actually shut down until the I/O is received.- Overrides:
shutdown
in classNonBlockingReader
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-