Class DuplicatedInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class DuplicatedInputStream
    extends java.io.InputStream
    Utility class that duplicates a single input stream to multiple input streams. The source input stream is read only once.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      static java.io.InputStream[] createStreams​(java.io.InputStream is, int duplicates)
      Returns an array of InputStreams each of which will receive a copy of the original input stream.
      static java.io.InputStream[] createStreams​(java.io.InputStream is, int duplicates, int bufSize)  
      int read()
      • Methods inherited from class java.io.InputStream

        close, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • createStreams

        public static java.io.InputStream[] createStreams​(java.io.InputStream is,
                                                          int duplicates)
        Returns an array of InputStreams each of which will receive a copy of the original input stream. The original InputStream is read only once. Once the default buffer size (8192) has been reached a reading stream will block until all streams have read the same data.
        Parameters:
        is -
        duplicates -
        Returns:
        the input streams
      • createStreams

        public static java.io.InputStream[] createStreams​(java.io.InputStream is,
                                                          int duplicates,
                                                          int bufSize)
      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • available

        public int available()
                      throws java.io.IOException
        Overrides:
        available in class java.io.InputStream
        Throws:
        java.io.IOException