# FilterOutputStream

public class **FilterOutputStream** extends [OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html)  

|---|---|---|
| Known Direct Subclasses [BufferedOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/BufferedOutputStream.html), [CheckedOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/CheckedOutputStream.html), [CipherOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/CipherOutputStream.html), [DataOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/DataOutputStream.html), [DeflaterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html), [DigestOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/DigestOutputStream.html), [InflaterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/InflaterOutputStream.html), [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) |---|---| | [BufferedOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/BufferedOutputStream.html) | The class implements a buffered output stream. | | [CheckedOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/CheckedOutputStream.html) | An output stream that also maintains a checksum of the data being written. | | [CipherOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/CipherOutputStream.html) | A CipherOutputStream is composed of an OutputStream and a Cipher so that write() methods first process the data before writing them out to the underlying OutputStream. | | [DataOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/DataOutputStream.html) | A data output stream lets an application write primitive Java data types to an output stream in a portable way. | | [DeflaterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html) | This class implements an output stream filter for compressing data in the "deflate" compression format. | | [DigestOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/DigestOutputStream.html) | A transparent stream that updates the associated message digest using the bits going through the stream. | | [InflaterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/InflaterOutputStream.html) | Implements an output stream filter for uncompressing data stored in the "deflate" compression format. | | [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) | A `PrintStream` adds functionality to another output stream, namely the ability to print representations of various data values conveniently. | |||

|---|---|---|
| Known Indirect Subclasses [GZIPOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPOutputStream.html), [JarOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/jar/JarOutputStream.html), [ZipOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipOutputStream.html) |---|---| | [GZIPOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPOutputStream.html) | This class implements a stream filter for writing compressed data in the GZIP file format. | | [JarOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/jar/JarOutputStream.html) | The `JarOutputStream` class is used to write the contents of a JAR file to any output stream. | | [ZipOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipOutputStream.html) | This class implements an output stream filter for writing files in the ZIP file format. | |||

This class is the superclass of all classes that filter output
streams. These streams sit on top of an already existing output
stream (the *underlying* output stream) which it uses as its
basic sink of data, but possibly transforming the data along the
way or providing additional functionality.


The class `FilterOutputStream` itself simply overrides
all methods of `OutputStream` with versions that pass
all requests to the underlying output stream. Subclasses of
`FilterOutputStream` may further override some of these
methods as well as provide additional methods and fields.

### Field Summary

|---|---|---|
| protected [OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) | [out](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#out) | The underlying output stream to be filtered. |

### Public Constructor Summary

|---|---|
|   | [FilterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#FilterOutputStream(java.io.OutputStream))([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out) Creates an output stream filter built on top of the specified underlying output stream. |

### Public Method Summary

|---|---|
| void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#close())() Closes this output stream and releases any system resources associated with the stream. |
| void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#flush())() Flushes this output stream and forces any buffered output bytes to be written out to the stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#write(byte[]))(byte\[\] b) Writes `b.length` bytes to this output stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#write(byte[],%20int,%20int))(byte\[\] b, int off, int len) Writes `len` bytes from the specified `byte` array starting at offset `off` to this output stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#write(int))(int b) Writes the specified `byte` to this output stream. |

### Inherited Method Summary

From class [java.io.OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html)

|---|---|
| void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#close())() Closes this output stream and releases any system resources associated with this stream. |
| void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#flush())() Flushes this output stream and forces any buffered output bytes to be written out. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#write(byte[]))(byte\[\] b) Writes `b.length` bytes from the specified byte array to this output stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#write(byte[],%20int,%20int))(byte\[\] b, int off, int len) Writes `len` bytes from the specified byte array starting at offset `off` to this output stream. |
| abstract void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#write(int))(int b) Writes the specified byte to this output stream. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.io.Closeable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html#close())() Closes this stream and releases any system resources associated with it. |

From interface [java.io.Flushable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Flushable.html)

|---|---|
| abstract void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Flushable.html#flush())() Flushes this stream by writing any buffered output to the underlying stream. |

From interface [java.lang.AutoCloseable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html#close())() Closes this resource, relinquishing any underlying resources. |

## Fields

#### protected [OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html)
**out**

The underlying output stream to be filtered.

## Public Constructors

#### public
**FilterOutputStream**
([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out)

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, or `null` if this instance is to be created without an underlying stream. |
|---|---|

## Public Methods

#### public void
**close**
()

Closes this output stream and releases any system resources
associated with the stream.


The `close` method of `FilterOutputStream`
calls its `flush` method, and then calls the
`close` method of its underlying output stream.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#flush()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#out`

#### public void
**flush**
()

Flushes this output stream and forces any buffered output bytes
to be written out to the stream.


The `flush` method of `FilterOutputStream`
calls the `flush` method of its underlying output stream.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#out`

#### public void
**write**
(byte\[\] b)

Writes `b.length` bytes to this output stream.


The `write` method of `FilterOutputStream`
calls its `write` method of three arguments with the
arguments `b`, `0`, and
`b.length`.


Note that this method does not call the one-argument
`write` method of its underlying stream with the single
argument `b`.

##### Parameters

| b | the data to be written. |
|---|---|

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#write(byte[],%20int,%20int)`

#### public void
**write**
(byte\[\] b, int off, int len)

Writes `len` bytes from the specified
`byte` array starting at offset `off` to
this output stream.


The `write` method of `FilterOutputStream`
calls the `write` method of one argument on each
`byte` to output.


Note that this method does not call the `write` method
of its underlying input stream with the same arguments. Subclasses
of `FilterOutputStream` should provide a more efficient
implementation of this method.

##### Parameters

| b | the data. |
| off | the start offset in the data. |
| len | the number of bytes to write. |
|---|---|

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#write(int)`

#### public void
**write**
(int b)

Writes the specified `byte` to this output stream.


The `write` method of `FilterOutputStream`
calls the `write` method of its underlying output stream,
that is, it performs out.write(b).


Implements the abstract write method of OutputStream.

##### Parameters

| b | the `byte`. |
|---|---|

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs. |
|---|---|