Class TeeInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class TeeInputStream
    extends InputStream
    An input stream which copies anything read through it to another stream.
    • Constructor Detail

      • TeeInputStream

        public TeeInputStream​(InputStream input,
                              OutputStream output)
        Base constructor.
        Parameters:
        input - input stream to be wrapped.
        output - output stream to copy any input read to.
    • Method Detail

      • read

        public int read​(byte[] buf,
                        int off,
                        int len)
                 throws IOException
        Description copied from class: InputStream
        Reads up to byteCount bytes from this stream and stores them in the byte array buffer starting at byteOffset. Returns the number of bytes actually read or -1 if the end of the stream has been reached.
        Overrides:
        read in class InputStream
        Throws:
        IOException - if the stream is closed or another IOException occurs.
      • read

        public int read()
                 throws IOException
        Description copied from class: InputStream
        Reads a single byte from this stream and returns it as an integer in the range from 0 to 255. Returns -1 if the end of the stream has been reached. Blocks until one byte has been read, the end of the source stream is detected or an exception is thrown.
        Specified by:
        read in class InputStream
        Throws:
        IOException - if the stream is closed or another IOException occurs.
      • close

        public void close()
                   throws IOException
        Description copied from class: InputStream
        Closes this stream. Concrete implementations of this class should free any resources during close. This implementation does nothing.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Overrides:
        close in class InputStream
        Throws:
        IOException - if an error occurs while closing this stream.