Package com.google.common.io
Class MultiInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.google.common.io.MultiInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
final class MultiInputStream extends java.io.InputStreamAnInputStreamthat concatenates multiple substreams. At most one stream will be open at a time.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.InputStreaminprivate java.util.Iterator<? extends ByteSource>it
-
Constructor Summary
Constructors Constructor Description MultiInputStream(java.util.Iterator<? extends ByteSource> it)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidadvance()Closes the current input stream and opens the next one, if any.intavailable()voidclose()booleanmarkSupported()intread()intread(byte[] b, int off, int len)longskip(long n)
-
-
-
Field Detail
-
it
private java.util.Iterator<? extends ByteSource> it
-
in
private java.io.InputStream in
-
-
Constructor Detail
-
MultiInputStream
public MultiInputStream(java.util.Iterator<? extends ByteSource> it) throws java.io.IOException
Creates a new instance.- Parameters:
it- an iterator of I/O suppliers that will provide each substream- Throws:
java.io.IOException
-
-
Method Detail
-
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
-
advance
private void advance() throws java.io.IOExceptionCloses the current input stream and opens the next one, if any.- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
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
-
-