Package it.unimi.dsi.io
Class MultipleInputStream
java.lang.Object
java.io.InputStream
it.unimi.dsi.io.MultipleInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
A multiple input stream.
Instances of this class encapsulate a sequence of input streams.
When one of the streams is exhausted, the multiple stream behaves as if on an end of file.
However, after calling reset()
the stream is again readable, and positioned
at the start of the following stream.
-
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
static InputStream
getStream
(InputStream[] inputStream) Returns an input stream encapsulating a nonempty array of input streams.static InputStream
getStream
(InputStream[] inputStream, int offset, int length) Returns an input stream encapsulating a nonempty fragment of an array of input streams.boolean
int
read()
int
read
(byte[] b) int
read
(byte[] b, int off, int len) void
reset()
long
skip
(long n) Methods inherited from class java.io.InputStream
mark, nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Method Details
-
getStream
Returns an input stream encapsulating a nonempty fragment of an array of input streams.- Parameters:
inputStream
- an array of input streams, that will be encapsulated.offset
- the first input stream that will be encapsulated.length
- the number of input streams to be encapsulated.- Returns:
- an input stream encapsulating the argument streams (the only argument, if length is 1).
-
getStream
Returns an input stream encapsulating a nonempty array of input streams.Note that if
inputStream.length
is 1 this method will return the only stream that should be encapsulated.- Parameters:
inputStream
- an array of input streams, that will be encapsulated.- Returns:
- an input stream encapsulating the argument streams (the only argument, if the length is 1).
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-