
public class FilterOutputStream extends OutputStream
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.FilterOutputStream| Modifier and Type | Field and Description |
|---|---|
protected OutputStream |
out
The target output stream for this filter stream.
|
| Constructor and Description |
|---|
FilterOutputStream(OutputStream out)
Constructs a new
FilterOutputStream with out as its
target stream. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this stream.
|
void |
flush()
Ensures that all pending data is sent out to the target stream.
|
void |
write(byte[] buffer,
int offset,
int length)
Writes
count bytes from the byte array buffer starting at
offset to the target stream. |
void |
write(int oneByte)
Writes one byte to the target stream.
|
writeprotected OutputStream out
public FilterOutputStream(OutputStream out)
FilterOutputStream with out as its
target stream.out - the target stream that this stream writes to.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOException - if an error occurs attempting to close this stream.public void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOException - if an error occurs attempting to flush this stream.public void write(byte[] buffer,
int offset,
int length)
throws IOException
count bytes from the byte array buffer starting at
offset to the target stream.write in class OutputStreambuffer - the buffer to write.offset - the index of the first byte in buffer to write.length - the number of bytes in buffer to write.IndexOutOfBoundsException - if offset < 0 or count < 0, or if
offset + count is bigger than the length of
buffer.IOException - if an I/O error occurs while writing to this stream.public void write(int oneByte)
throws IOException
oneByte is written.write in class OutputStreamoneByte - the byte to be written.IOException - if an I/O error occurs while writing to this stream.Copyright © 2018. All rights reserved.