Package com.saperion.common.io
Class ConcatenationInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.saperion.common.io.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 severalinput 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 isserializable
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)
-
-
-
Method Detail
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException
- Overrides:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.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 isnull
or does not contain any elements anEmptyInputStream
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 isnull
or does not contain any elements anEmptyInputStream
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
-
-