Class LogInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
de.intarsys.tools.stream.LogInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class LogInputStream extends FilterInputStream
An InputStream that logs any char read.

This stream is piped in the reading process, any characters read are written to an associated OutputStream object.

 Client -> LogInputStream -> InputStream -> Source
            |
            v
           OutputStream
 
  • Constructor Details

    • LogInputStream

      public LogInputStream(InputStream newin, OutputStream newlog)
      SplitStream - Konstruktorkommentar.
      Parameters:
      newin -
      newlog -
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterInputStream
      Throws:
      IOException
    • getLog

      public OutputStream getLog()
    • read

      public int read() throws IOException
      Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

      A subclass must provide an implementation of this method.

      Overrides:
      read in class FilterInputStream
      Returns:
      the next byte of data, or -1 if the end of the stream is reached.
      Throws:
      IOException - if an I/O error occurs.
    • 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 blocks until some input is available.

      This method simply performs in.read(b, off, len) and returns the result.

      Overrides:
      read in class FilterInputStream
      Parameters:
      b - the buffer into which the data is read.
      off - the start offset of the data.
      len - the maximum number of bytes read.
      Returns:
      the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
      Throws:
      IOException - if an I/O error occurs.
      See Also:
    • setLog

      public void setLog(OutputStream newLog)