APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.org.jline.utils

public abstract Class NonBlockingReader

extends Reader
Class Inheritance
Known Direct Subclasses
jdk.internal.org.jline.utils.NonBlockingReaderImpl, jdk.internal.org.jline.utils.NonBlocking.NonBlockingInputStreamReader, jdk.internal.org.jline.utils.NonBlockingPumpReader
Imports
java.io.IOException, .Reader

Non blocking reader

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
Inherited from java.io.Reader:
lock

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
public int

Returns:

-1 on eof, -2 if the timeout expired with no available input or the character that was read (without consuming it).
peek
(long
The amount of time to wait, 0 == forever
timeout
)

Peeks to see if there is a byte waiting in the input stream without actually consuming the byte.

public int
read()

Overrides java.io.Reader.read.

Reads a single character.

public int

Returns:

The character read, -1 if EOF is reached, or -2 if the read timed out.
read
(long
The amount of time to wait for the character
timeout
)

Attempts to read a character from the input stream for a specific period of time.

public int
read(char[]
the buffer
b
,
int
the offset in the buffer
off
,
int
the maximum number of chars to read
len
)

Implements abstract java.io.Reader.read.

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.

protected abstract int

Returns:

The character read, -1 if EOF is reached, or -2 if the read timed out.
read
(long
The amount of time to wait for the character
timeout
,
boolean
trueif the character read must not be consumed
isPeek
)

Attempts to read a character from the input stream for a specific period of time.

public int
readBuffered(char[] b)

public int
readBuffered(char[] b, long timeout)

public abstract int
readBuffered(char[] b, int off, int len, long timeout)

public void
shutdown()

Shuts down the thread that is handling blocking I/O.

Inherited from java.io.Reader:
closemarkmarkSupportednullReaderofreadreadreadAllAsStringreadAllLinesreadyresetskiptransferTo

Field Detail

EOFback to summary
public static final int EOF
READ_EXPIREDback to summary
public static final int READ_EXPIRED

Constructor Detail

NonBlockingReaderback to summary
public NonBlockingReader()

Method Detail

availableback to summary
public int available()
peekback to summary
public int peek(long timeout) throws IOException

Peeks to see if there is a byte waiting in the input stream without actually consuming the byte.

Parameters
timeout:long

The amount of time to wait, 0 == forever

Returns:int

-1 on eof, -2 if the timeout expired with no available input or the character that was read (without consuming it).

Exceptions
IOException:
if anything wrong happens
readback to summary
public int read() throws IOException

Overrides java.io.Reader.read.

Doc from java.io.Reader.read.

Reads a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.

Subclasses that intend to support efficient single-character input should override this method.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
readback to summary
public int read(long timeout) throws IOException

Attempts to read a character from the input stream for a specific period of time.

Parameters
timeout:long

The amount of time to wait for the character

Returns:int

The character read, -1 if EOF is reached, or -2 if the read timed out.

Exceptions
IOException:
if anything wrong happens
readback to summary
public int read(char[] b, int off, int len) throws IOException

Implements abstract java.io.Reader.read.

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.

Parameters
b:char[]

the buffer

off:int

the offset in the buffer

len:int

the maximum number of chars to read

Annotations
@Override
Exceptions
IOException:
if anything wrong happens
readback to summary
protected abstract int read(long timeout, boolean isPeek) throws IOException

Attempts to read a character from the input stream for a specific period of time.

Parameters
timeout:long

The amount of time to wait for the character

isPeek:boolean

trueif the character read must not be consumed

Returns:int

The character read, -1 if EOF is reached, or -2 if the read timed out.

Exceptions
IOException:
if anything wrong happens
readBufferedback to summary
public int readBuffered(char[] b) throws IOException
readBufferedback to summary
public int readBuffered(char[] b, long timeout) throws IOException
readBufferedback to summary
public abstract int readBuffered(char[] b, int off, int len, long timeout) throws IOException
shutdownback to summary
public void shutdown()

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.