Package org.bouncycastle.util.io
Class TeeOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.bouncycastle.util.io.TeeOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
public class TeeOutputStream extends OutputStream
An output stream which copies anything written into it to another stream.
-
-
Constructor Summary
Constructors Constructor Description TeeOutputStream(OutputStream output1, OutputStream output2)Base constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this stream.voidflush()Flushes this stream.voidwrite(byte[] buf)Equivalent towrite(buffer, 0, buffer.length).voidwrite(byte[] buf, int off, int len)Writescountbytes from the byte arraybufferstarting at positionoffsetto this stream.voidwrite(int b)Writes a single byte to this stream.
-
-
-
Constructor Detail
-
TeeOutputStream
public TeeOutputStream(OutputStream output1, OutputStream output2)
Base constructor.- Parameters:
output1- the output stream that is wrapped.output2- a secondary stream that anything written to output1 is also written to.
-
-
Method Detail
-
write
public void write(byte[] buf) throws IOExceptionDescription copied from class:OutputStreamEquivalent towrite(buffer, 0, buffer.length).- Overrides:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] buf, int off, int len) throws IOExceptionDescription copied from class:OutputStreamWritescountbytes from the byte arraybufferstarting at positionoffsetto this stream.- Overrides:
writein classOutputStream- Parameters:
buf- the buffer to be written.off- the start position inbufferfrom where to get bytes.len- the number of bytes frombufferto write to this stream.- Throws:
IOException- if an error occurs while writing to this stream.
-
write
public void write(int b) throws IOExceptionDescription copied from class:OutputStreamWrites a single byte to this stream. Only the least significant byte of the integeroneByteis written to the stream.- Specified by:
writein classOutputStream- Parameters:
b- the byte to be written.- Throws:
IOException- if an error occurs while writing to this stream.
-
flush
public void flush() throws IOExceptionDescription copied from class:OutputStreamFlushes this stream. Implementations of this method should ensure that any buffered data is written out. This implementation does nothing.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if an error occurs while flushing this stream.
-
close
public void close() throws IOExceptionDescription copied from class:OutputStreamCloses this stream. Implementations of this method should free any resources used by the stream. This implementation does nothing.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- if an error occurs while closing this stream.
-
-