Class LinePipedInputStream

java.lang.Object
java.io.InputStream
java.io.PipedInputStream
org.aesh.terminal.tty.utils.LinePipedInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class LinePipedInputStream extends PipedInputStream
A PipedInputStream that reads data line by line, stopping at newline characters.
Author:
Stale W. Pedersen
  • Constructor Details

    • LinePipedInputStream

      public LinePipedInputStream(int pipeSize)
      Creates a new LinePipedInputStream with the specified pipe size.
      Parameters:
      pipeSize - the size of the pipe buffer
    • LinePipedInputStream

      public LinePipedInputStream(PipedOutputStream src) throws IOException
      Creates a new LinePipedInputStream connected to the specified PipedOutputStream.
      Parameters:
      src - the piped output stream to connect to
      Throws:
      IOException - if an I/O error occurs
  • Method Details

    • read

      public int read(byte[] b, int off, int len) throws IOException
      Reads up to len bytes of data from this input stream into an array of bytes. This method reads one line at a time, stopping when a newline character is encountered.
      Overrides:
      read in class PipedInputStream
      Parameters:
      b - the buffer into which the data is read
      off - the start offset in array b at which the data is written
      len - the maximum number of bytes to read
      Returns:
      the total number of bytes read into the buffer, or -1 if there is no more data
      Throws:
      IOException - if an I/O error occurs