Package com.jalios.io
Class MultiInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.jalios.io.MultiInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class MultiInputStream extends java.io.InputStreamThis class is a facade on an array of InputStream. When the first InputStream is empty it reads in the next.- Author:
- Olivier Dedieu
-
-
Constructor Summary
Constructors Constructor Description MultiInputStream(java.io.InputStream[] array)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Returns the number of bytes that can be read from this input stream without blocking.voidclose()Closes this input stream and releases any system resources associated with the stream.voidmark(int readlimit)Marks the current position in this input stream.booleanmarkSupported()Tests if this input stream supports themarkandresetmethods.intread()Reads the next byte of data from this input stream.
-
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionReads the next byte of data from this input stream. The value byte is returned as anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Specified by:
readin classjava.io.InputStream- Returns:
- the next byte of data, or
-1if the end of the stream is reached. - Throws:
java.io.IOException- if an I/O error occurs.- Since:
- JDK1.0
-
available
public int available() throws java.io.IOExceptionReturns the number of bytes that can be read from this input stream without blocking. The available method ofInputStreamreturns0. This method should be overridden by subclasses.- Overrides:
availablein classjava.io.InputStream- Returns:
- the number of bytes that can be read from this input stream without blocking.
- Throws:
java.io.IOException- if an I/O error occurs.- Since:
- JDK1.0
-
close
public void close() throws java.io.IOExceptionCloses this input stream and releases any system resources associated with the stream.The
closemethod ofInputStreamdoes nothing.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- if an I/O error occurs.- Since:
- JDK1.0
-
mark
public void mark(int readlimit)
Marks the current position in this input stream. A subsequent call to theresetmethod repositions this stream at the last marked position so that subsequent reads re-read the same bytes.The
readlimitarguments tells this input stream to allow that many bytes to be read before the mark position gets invalidated.- Overrides:
markin classjava.io.InputStream- Parameters:
readlimit- the maximum limit of bytes that can be read before the mark position becomes invalid.- Since:
- JDK1.0
- See Also:
InputStream.reset()
-
markSupported
public boolean markSupported()
Tests if this input stream supports themarkandresetmethods. ThemarkSupportedmethod ofInputStreamreturnsfalse.- Overrides:
markSupportedin classjava.io.InputStream- Returns:
trueif this true type supports the mark and reset method;falseotherwise.- Since:
- JDK1.0
- See Also:
InputStream.mark(int),InputStream.reset()
-
-