Package it.unimi.dsi.io
Class MultipleInputStream
java.lang.Object
java.io.InputStream
it.unimi.dsi.io.MultipleInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
public class MultipleInputStream extends InputStream
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 Type Method Description intavailable()voidclose()static InputStreamgetStream(InputStream[] inputStream)Returns an input stream encapsulating a nonempty array of input streams.static InputStreamgetStream(InputStream[] inputStream, int offset, int length)Returns an input stream encapsulating a nonempty fragment of an array of input streams.booleanmarkSupported()intread()intread(byte[] b)intread(byte[] b, int off, int len)voidreset()longskip(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.lengthis 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:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-