Class DelegatingOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
- Direct Known Subclasses:
XOROutputStream
The class DelegatingOutputStream
itself simply overrides all methods of OutputStream
with
versions that pass all requests to the underlying output stream. Subclasses of DelegatingOutputStream
may further override some of these methods as well as provide additional methods and fields.
Note: The only difference to FilterOutputStream
is that DelegatingOutputStream
does not override OutputStream.write(byte[])
or OutputStream.write(byte[], int, int)
but rather exposes the original
implementations of InputStream
which call write(int)
instead of their delegate counterparts.
- Author:
- Eike Stepper
-
Field Summary
Modifier and TypeFieldDescriptionprotected OutputStream
The underlying output stream to be filtered. -
Constructor Summary
ConstructorDescriptionCreates an output stream filter built on top of the specified underlying output stream. -
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
(int b) Writes the specifiedbyte
to this output stream.Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Field Details
-
out
The underlying output stream to be filtered.
-
-
Constructor Details
-
DelegatingOutputStream
Creates an output stream filter built on top of the specified underlying output stream.- Parameters:
out
- the underlying output stream to be assigned to the field this.out for later use, ornull
if this instance is to be created without an underlying stream.
-
-
Method Details
-
getDelegate
-
write
Writes the specifiedbyte
to this output stream.The
write
method ofDelegatingOutputStream
calls thewrite
method of its underlying output stream, that is, it performs out.write(b).Implements the abstract write method of OutputStream.
- Specified by:
write
in classOutputStream
- Parameters:
b
- thebyte
.- Throws:
IOException
- if an I/O error occurs.
-
flush
Flushes this output stream and forces any buffered output bytes to be written out to the stream.The
flush
method ofDelegatingOutputStream
calls theflush
method of its underlying output stream.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- if an I/O error occurs.- See Also:
-
close
Closes this output stream and releases any system resources associated with the stream.The
close
method ofDelegatingOutputStream
calls itsflush
method, and then calls theclose
method of its underlying output stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
- if an I/O error occurs.- See Also:
-