Package com.jalios.io

Class MultiInputStream

java.lang.Object
java.io.InputStream
com.jalios.io.MultiInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class MultiInputStream extends InputStream
This class is a facade on an array of InputStream. When the first InputStream is empty it reads in the next.
Author:
Olivier Dedieu
  • Constructor Details

    • MultiInputStream

      public MultiInputStream(InputStream[] array)
  • Method Details

    • read

      public int read() throws IOException
      Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.
      Specified by:
      read in class InputStream
      Returns:
      the next byte of data, or -1 if the end of the stream is reached.
      Throws:
      IOException - if an I/O error occurs.
      Since:
      JDK1.0
    • available

      public int available() throws IOException
      Returns the number of bytes that can be read from this input stream without blocking. The available method of InputStream returns 0. This method should be overridden by subclasses.
      Overrides:
      available in class InputStream
      Returns:
      the number of bytes that can be read from this input stream without blocking.
      Throws:
      IOException - if an I/O error occurs.
      Since:
      JDK1.0
    • close

      public void close() throws IOException
      Closes this input stream and releases any system resources associated with the stream.

      The close method of InputStream does nothing.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      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 the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

      The readlimit arguments tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

      Overrides:
      mark in class InputStream
      Parameters:
      readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid.
      Since:
      JDK1.0
      See Also:
    • markSupported

      public boolean markSupported()
      Tests if this input stream supports the mark and reset methods. The markSupported method of InputStream returns false.
      Overrides:
      markSupported in class InputStream
      Returns:
      true if this true type supports the mark and reset method; false otherwise.
      Since:
      JDK1.0
      See Also: