public class FilterOutputStream extends OutputStream
OutputStream. This class simply overrides all the
methods in OutputStream to redirect them to the
underlying stream. Subclasses provide actual filtering.| Modifier and Type | Field and Description |
|---|---|
protected OutputStream |
out
This is the subordinate
OutputStream that this class
redirects its method calls to. |
| Constructor and Description |
|---|
FilterOutputStream(OutputStream out)
This method initializes an instance of
FilterOutputStream
to write to the specified subordinate OutputStream. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
This method closes the underlying
OutputStream. |
void |
flush()
This method attempt to flush all buffered output to be written to the
underlying output sink.
|
void |
write(byte[] buf)
This method writes all the bytes in the specified array to the underlying
OutputStream. |
void |
write(byte[] buf,
int offset,
int len)
This method calls the
write(int) method len
times for all bytes from the array buf starting at index
offset. |
void |
write(int b)
This method writes a single byte of output to the underlying
OutputStream. |
protected OutputStream out
OutputStream that this class
redirects its method calls to.public FilterOutputStream(OutputStream out)
FilterOutputStream
to write to the specified subordinate OutputStream.out - The OutputStream to write topublic void close() throws IOException
OutputStream. Any
further attempts to write to this stream may throw an exception.close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOException - If an error occurspublic void flush() throws IOException
flush in interface Flushableflush in class OutputStreamIOException - If an error occurspublic void write(int b) throws IOException
OutputStream.write in class OutputStreamb - The byte to write, passed as an int.IOException - If an error occurspublic void write(byte[] buf) throws IOException
OutputStream. It does this by calling the three parameter
version of this method - write(byte[], int, int) in this
class instead of writing to the underlying OutputStream
directly. This allows most subclasses to avoid overriding this method.write in class OutputStreambuf - The byte array to write bytes fromIOException - If an error occurspublic void write(byte[] buf, int offset, int len) throws IOException
write(int) method len
times for all bytes from the array buf starting at index
offset. Subclasses should overwrite this method to get a
more efficient implementation.write in class OutputStreambuf - The byte array to write bytes fromoffset - The index into the array to start writing bytes fromlen - The number of bytes to writeIOException - If an error occurs