Package org.apache.commons.io.output
Class TeeOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.io.output.ProxyOutputStream
org.apache.commons.io.output.TeeOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Classic splitter of
OutputStream
. Named after the UNIX 'tee' command. It allows a stream to be branched off
so there are now two streams.-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorDescriptionTeeOutputStream
(OutputStream out, OutputStream branch) Constructs a TeeOutputStream. -
Method Summary
Methods inherited from class org.apache.commons.io.output.ProxyOutputStream
afterWrite, beforeWrite, handleIOException
-
Field Details
-
branch
The second OutputStream to write to. TODO Make private and final in 3.0.
-
-
Constructor Details
-
TeeOutputStream
Constructs a TeeOutputStream.- Parameters:
out
- the main OutputStreambranch
- the second OutputStream
-
-
Method Details
-
close
Closes both output streams.If closing the main output stream throws an exception, attempt to close the branch output stream.
If closing the main and branch output streams both throw exceptions, which exceptions is thrown by this method is currently unspecified and subject to change.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classProxyOutputStream
- Throws:
IOException
- if an I/O error occurs.
-
flush
Flushes both streams.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classProxyOutputStream
- Throws:
IOException
- if an I/O error occurs.
-
write
Writes the bytes to both streams.- Overrides:
write
in classProxyOutputStream
- Parameters:
b
- the bytes to write- Throws:
IOException
- if an I/O error occurs.
-
write
Writes the specified bytes to both streams.- Overrides:
write
in classProxyOutputStream
- Parameters:
b
- the bytes to writeoff
- The start offsetlen
- The number of bytes to write- Throws:
IOException
- if an I/O error occurs.
-
write
Writes a byte to both streams.- Overrides:
write
in classProxyOutputStream
- Parameters:
b
- the byte to write- Throws:
IOException
- if an I/O error occurs.
-