java.io
Class FilterOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
Direct Known Subclasses:
PrintStream

public class FilterOutputStream
extends OutputStream

This class is the common superclass of output stream classes that filter the output they write. These classes typically transform the data in some way prior to writing it out to another underlying OutputStream. This class simply overrides all the methods in OutputStream to redirect them to the underlying stream. Subclasses provide actual filtering.


Field Summary
protected  OutputStream out
          This is the subordinate OutputStream that this class redirects its method calls to.
 
Constructor Summary
FilterOutputStream(OutputStream out)
          This method initializes an instance of FilterOutputStream to write to the specified subordinate OutputStream.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

protected OutputStream out
This is the subordinate OutputStream that this class redirects its method calls to.

Constructor Detail

FilterOutputStream

public FilterOutputStream(OutputStream out)
This method initializes an instance of FilterOutputStream to write to the specified subordinate OutputStream.

Parameters:
out - The OutputStream to write to
Method Detail

close

public void close()
           throws IOException
This method closes the underlying OutputStream. Any further attempts to write to this stream may throw an exception.

Overrides:
close in class OutputStream
Throws:
IOException - If an error occurs

flush

public void flush()
           throws IOException
This method attempt to flush all buffered output to be written to the underlying output sink.

Overrides:
flush in class OutputStream
Throws:
IOException - If an error occurs

write

public void write(int b)
           throws IOException
This method writes a single byte of output to the underlying OutputStream.

Specified by:
write in class OutputStream
Parameters:
b - The byte to write, passed as an int.
Throws:
IOException - If an error occurs

write

public void write(byte[] buf)
           throws IOException
This method writes all the bytes in the specified array to the underlying 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.

Overrides:
write in class OutputStream
Parameters:
buf - The byte array to write bytes from
Throws:
IOException - If an error occurs

write

public void write(byte[] buf,
                  int offset,
                  int len)
           throws IOException
This method calls the 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.

Overrides:
write in class OutputStream
Parameters:
buf - The byte array to write bytes from
offset - The index into the array to start writing bytes from
len - The number of bytes to write
Throws:
IOException - If an error occurs