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 Detail
-
getStream
public static InputStream getStream(InputStream[] inputStream, int offset, int length)
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
public static InputStream getStream(InputStream[] inputStream)
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
public int available() throws IOException- Overrides:
availablein classInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classInputStream
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
reset
public void reset() throws IOException- Overrides:
resetin classInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Overrides:
skipin classInputStream- Throws:
IOException
-
-