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
FieldsModifier and TypeFieldDescriptionprotected OutputStreamThe underlying output stream to be filtered. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an output stream filter built on top of the specified underlying output stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this output stream and releases any system resources associated with the stream.voidflush()Flushes this output stream and forces any buffered output bytes to be written out to the stream.voidwrite(int b) Writes the specifiedbyteto 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, ornullif this instance is to be created without an underlying stream.
-
-
Method Details
-
getDelegate
-
write
Writes the specifiedbyteto this output stream.The
writemethod ofDelegatingOutputStreamcalls thewritemethod of its underlying output stream, that is, it performs out.write(b).Implements the abstract write method of OutputStream.
- Specified by:
writein 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
flushmethod ofDelegatingOutputStreamcalls theflushmethod of its underlying output stream.- Specified by:
flushin interfaceFlushable- Overrides:
flushin 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
closemethod ofDelegatingOutputStreamcalls itsflushmethod, and then calls theclosemethod of its underlying output stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- if an I/O error occurs.- See Also:
-