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.SerializableConcatenates severalinput streamsto another input stream so that if one reads the resulting stream it is the same as reading the streams one after another. A ConcatenationInputStream isserializableif 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 voidclose()static java.io.InputStreamcreate(java.io.InputStream... streams)Creates a new InputStream that concatenates the given streams.static java.io.InputStreamcreate(java.util.List<? extends java.io.InputStream> streams)Creates a new InputStream that concatenates the given streams.intread()intread(byte[] b, int off, int len)longskip(long n)
-
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein 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 isnullor does not contain any elements anEmptyInputStreamis 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 isnullor does not contain any elements anEmptyInputStreamis 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
-
-