Package com.saperion.common.io
Class ConcatenationInputStream
java.lang.Object
java.io.InputStream
com.saperion.common.io.ConcatenationInputStream
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
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:
-
Constructor Summary
ConstructorsConstructorDescriptionConcatenationInputStream
(List<? extends InputStream> streams) Creates a new ConcatenationInputStream that concatenates the given streams -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static InputStream
create
(InputStream... streams) Creates a new InputStream that concatenates the given streams.static InputStream
create
(List<? extends 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, skipNBytes, transferTo
-
Constructor Details
-
ConcatenationInputStream
Creates a new ConcatenationInputStream that concatenates the given streams- Parameters:
streams
- the streams to concatenate
-
-
Method Details
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
create
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
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
-