Package org.ka2ddo.util
Class DualOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.ka2ddo.util.DualOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
This FilterOutputStream subclass directs its output to both its primary and alternate contained streams.
- Author:
- Andrew Pavlin, KA2DDO
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorDescriptionDualOutputStream
(OutputStream out1, OutputStream out2) Creates an output stream filter built on top of the specified two underlying output streams. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this output stream and releases any system resources associated with the stream.void
flush()
Flushes this output stream and forces any buffered output bytes to be written out to the stream.void
write
(byte[] b) Writesb.length
bytes to this output stream.void
write
(byte[] b, int off, int len) Writeslen
bytes from the specifiedbyte
array starting at offsetoff
to this output stream.void
write
(int b) Writes the specifiedbyte
to this output stream.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
DualOutputStream
Creates an output stream filter built on top of the specified two underlying output streams.- Parameters:
out1
- the underlying output stream to be assigned to the fieldthis.out
for later use, ornull
if this instance is to be created without an underlying stream.out2
- the second output stream which should get a copy of all bytes written to this stream.
-
-
Method Details
-
write
Writes the specifiedbyte
to this output stream.The
write
method ofFilterOutputStream
calls thewrite
method of its underlying output stream, that is, it performsout.write(b)
.- Overrides:
write
in classFilterOutputStream
- Parameters:
b
- thebyte
.- Throws:
IOException
- if an I/O error occurs.
-
write
Writesb.length
bytes to this output stream.The
write
method ofDualOutputStream
calls itswrite
method of three arguments with the argumentsb
,0
, andb.length
.- Overrides:
write
in classFilterOutputStream
- Parameters:
b
- the data to be written.- Throws:
IOException
- if an I/O error occurs.- See Also:
-
write
Writeslen
bytes from the specifiedbyte
array starting at offsetoff
to this output stream.- Overrides:
write
in classFilterOutputStream
- Parameters:
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.- Throws:
IOException
- if an I/O error occurs.- See Also:
-
flush
Flushes this output stream and forces any buffered output bytes to be written out to the stream.The
flush
method ofDualOutputStream
calls theflush
method of its underlying output streams.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterOutputStream
- Throws:
IOException
- if an I/O error occurs.- See Also:
-
close
Closes this output stream and releases any system resources associated with the stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
- if an I/O error occurs.- See Also:
-