Class NonBlockingInputStream

java.lang.Object
java.io.InputStream
org.jline.utils.NonBlockingInputStream
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
NonBlockingInputStreamImpl, NonBlockingPumpInputStream

public abstract class NonBlockingInputStream extends InputStream
An input stream that supports non-blocking read operations with timeouts.

The NonBlockingInputStream class extends InputStream to provide non-blocking read operations. Unlike standard input streams, which block indefinitely until data is available or the end of the stream is reached, non-blocking input streams can be configured to return immediately or after a specified timeout if no data is available.

This class defines two special return values:

  • EOF (-1) - Indicates that the end of the stream has been reached
  • READ_EXPIRED (-2) - Indicates that the read operation timed out

This abstract class provides the framework for non-blocking input operations, with concrete implementations handling the details of how the non-blocking behavior is achieved (e.g., through NIO, separate threads, or native methods).

Non-blocking input streams are particularly useful for terminal applications that need to perform other tasks while waiting for user input, or that need to implement features like input timeouts or polling.