Class PumpReader

java.lang.Object
java.io.Reader
org.jline.utils.PumpReader
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

public class PumpReader extends Reader
A reader implementation with an associated writer for buffered character transfer.

The PumpReader class provides a Reader implementation with an associated Writer that allows characters to be written to the writer and then read from the reader. This creates a character pipe or pump that can be used to transfer character data between different components.

This class is particularly useful for:

  • Creating character streams for testing without actual I/O
  • Buffering characters between producer and consumer threads
  • Implementing character-based pipes with flow control
  • Simulating input for terminal emulation

The PumpReader maintains internal buffers for reading and writing, with both buffers backed by the same array. It provides methods for reading characters with optional timeouts and for checking the availability of characters without blocking.

This class is used in JLine for various purposes, including implementing non-blocking readers and for testing terminal input handling without actual terminal devices.