Package java.io
Class FilterOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Direct Known Subclasses:
BufferedOutputStream,CheckedOutputStream,CipherOutputStream,CipherOutputStream,DataOutputStream,DeflaterOutputStream,DigestOutputStream,InflaterOutputStream,PrintStream
public class FilterOutputStream extends OutputStream
Wraps an existing
OutputStream and performs some transformation on
the output data while it is being written. Transformations can be anything
from a simple byte-wise filtering output data to an on-the-fly compression or
decompression of the underlying stream. Output streams that wrap another
output stream and provide some additional functionality on top of it usually
inherit from this class.- See Also:
FilterOutputStream
-
Field Summary
Fields Modifier and Type Field Description protected OutputStreamoutThe target output stream for this filter stream. -
Constructor Summary
Constructors Constructor Description FilterOutputStream(OutputStream out)Constructs a newFilterOutputStreamwithoutas its target stream. -
Method Summary
Modifier and Type Method Description voidclose()Closes this stream.voidflush()Ensures that all pending data is sent out to the target stream.voidwrite(byte[] buffer, int offset, int length)Writescountbytes from the byte arraybufferstarting atoffsetto the target stream.voidwrite(int oneByte)Writes one byte to the target stream.Methods inherited from class java.io.OutputStream
write
-
Field Details
-
out
The target output stream for this filter stream.
-
-
Constructor Details
-
FilterOutputStream
Constructs a newFilterOutputStreamwithoutas its target stream.- Parameters:
out- the target stream that this stream writes to.
-
-
Method Details
-
close
Closes this stream. This implementation closes the target stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- if an error occurs attempting to close this stream.
-
flush
Ensures that all pending data is sent out to the target stream. This implementation flushes the target stream.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if an error occurs attempting to flush this stream.
-
write
Writescountbytes from the byte arraybufferstarting atoffsetto the target stream.- Overrides:
writein classOutputStream- Parameters:
buffer- the buffer to write.offset- the index of the first byte inbufferto write.length- the number of bytes inbufferto write.- Throws:
IndexOutOfBoundsException- ifoffset < 0orcount < 0, or ifoffset + countis bigger than the length ofbuffer.IOException- if an I/O error occurs while writing to this stream.
-
write
Writes one byte to the target stream. Only the low order byte of the integeroneByteis written.- Specified by:
writein classOutputStream- Parameters:
oneByte- the byte to be written.- Throws:
IOException- if an I/O error occurs while writing to this stream.
-