Package org.bouncycastle.util.io
Class TeeInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.bouncycastle.util.io.TeeInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class TeeInputStream extends InputStream
An input stream which copies anything read through it to another stream.
-
-
Constructor Summary
Constructors Constructor Description TeeInputStream(InputStream input, OutputStream output)Base constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this stream.OutputStreamgetOutputStream()intread()Reads a single byte from this stream and returns it as an integer in the range from 0 to 255.intread(byte[] buf)Equivalent toread(buffer, 0, buffer.length).intread(byte[] buf, int off, int len)Reads up tobyteCountbytes from this stream and stores them in the byte arraybufferstarting atbyteOffset.-
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset, skip
-
-
-
-
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) throws IOExceptionDescription copied from class:InputStreamEquivalent toread(buffer, 0, buffer.length).- Overrides:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] buf, int off, int len) throws IOExceptionDescription copied from class:InputStreamReads up tobyteCountbytes from this stream and stores them in the byte arraybufferstarting atbyteOffset. Returns the number of bytes actually read or -1 if the end of the stream has been reached.- Overrides:
readin classInputStream- Throws:
IOException- if the stream is closed or another IOException occurs.
-
read
public int read() throws IOExceptionDescription copied from class:InputStreamReads 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:
readin classInputStream- Throws:
IOException- if the stream is closed or another IOException occurs.
-
close
public void close() throws IOExceptionDescription copied from class:InputStreamCloses this stream. Concrete implementations of this class should free any resources during close. This implementation does nothing.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException- if an error occurs while closing this stream.
-
getOutputStream
public OutputStream getOutputStream()
-
-