Class InputStreamSplitter

java.lang.Object
java.io.InputStream
net.sf.basedb.util.InputStreamSplitter
All Implemented Interfaces:
Closeable, AutoCloseable

public class InputStreamSplitter
extends InputStream
This class can be used to split an input stream into one or more additional output streams. When data is read from this input stream the bytes are also written to the specified output streams with one of the OutputStream.write(int) or OutputStream.write(byte[], int, int) methods.
Version:
2.0
Author:
nicklas
Last modified
$Date: 2010-08-13 10:50:27 +0200 (fr, 13 aug 2010) $
  • Field Details

    • numRead

      private int numRead
    • in

      private final InputStream in
      The source input stream to read from.
    • copyTo

      private final OutputStream[] copyTo
      Streams to copy the data to.
    • copySkipped

      private final boolean copySkipped
      If the skip(long) method should copy to the output streams or no.
    • readToEnd

      private final boolean readToEnd
      If the remainder of the input stream should be copied if it is closed before the end.
  • Constructor Details

    • InputStreamSplitter

      public InputStreamSplitter​(InputStream in, OutputStream... copyTo)
      Create a new input stream splitter. Skipped bytes are not copied and the remainder of the stream is not copied if closed.
      Parameters:
      in - The input stream to read from
      copyTo - The output streams to copy data to
    • InputStreamSplitter

      public InputStreamSplitter​(InputStream in, boolean copySkipped, boolean readToEnd, OutputStream... copyTo)
      Create a new input stream splitter. Skipped bytes are not copied and the remainder of the stream is not copied if closed.
      Parameters:
      in - The input stream to read from. Null is not allowed
      copySkipped - TRUE if skipped bytes should be copied, FALSE otherwise
      readToEnd - If the remainder of the input stream should be copied if it is closed before the end
      copyTo - The output streams to copy data to. Null is not allowed
      Since:
      2.4
  • Method Details