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.InputStream
AnInputStream
that 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.InputStream
in
private 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 void
advance()
Closes the current input stream and opens the next one, if any.int
available()
void
close()
boolean
markSupported()
int
read()
int
read(byte[] b, int off, int len)
long
skip(long n)
-
-
-
Field Detail
-
it
private java.util.Iterator<? extends ByteSource> it
-
in
@CheckForNull 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
advance
private void advance() throws java.io.IOException
Closes the current input stream and opens the next one, if any.- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException
- Overrides:
available
in classjava.io.InputStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.InputStream
-
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
-
-