Class ConcatenationInputStream

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

    public class ConcatenationInputStream
    extends java.io.InputStream
    implements java.io.Serializable
    Concatenates several input streams to another input stream so that if one reads the resulting stream it is the same as reading the streams one after another. A ConcatenationInputStream is serializable if and only if all the streams concatenated are serializable.
    Author:
    jschwarz
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ConcatenationInputStream​(java.util.List<? extends java.io.InputStream> streams)
      Creates a new ConcatenationInputStream that concatenates the given streams
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      static java.io.InputStream create​(java.io.InputStream... streams)
      Creates a new InputStream that concatenates the given streams.
      static java.io.InputStream create​(java.util.List<? extends java.io.InputStream> streams)
      Creates a new InputStream that concatenates the given streams.
      int read()  
      int read​(byte[] b, int off, int len)  
      long skip​(long n)  
      • Methods inherited from class java.io.InputStream

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

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

      • ConcatenationInputStream

        public ConcatenationInputStream​(java.util.List<? extends java.io.InputStream> streams)
        Creates a new ConcatenationInputStream that concatenates the given streams
        Parameters:
        streams - the streams to concatenate
    • Method Detail

      • read

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

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • skip

        public long skip​(long n)
                  throws java.io.IOException
        Overrides:
        skip in class java.io.InputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException
      • create

        public static java.io.InputStream create​(java.io.InputStream... streams)
        Creates a new InputStream that concatenates the given streams.

        If streams is null or does not contain any elements an EmptyInputStream is created. If streams contains one and only one element this element is returned. Otherwise a ConcatenationInputStream is returned.

        Parameters:
        streams - the streams to concatenate
        Returns:
        a new InputStream that concatenates the given streams
      • create

        public static java.io.InputStream create​(java.util.List<? extends java.io.InputStream> streams)
        Creates a new InputStream that concatenates the given streams.

        If streams is null or does not contain any elements an EmptyInputStream is created. If streams contains one and only one element this element is returned. Otherwise a ConcatenationInputStream is returned.

        Parameters:
        streams - the streams to concatenate
        Returns:
        a new InputStream that concatenates the given streams