# GZIPOutputStream

public class **GZIPOutputStream** extends [DeflaterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html)  
This class implements a stream filter for writing compressed data in
the GZIP file format.

### Field Summary

|---|---|---|
| protected [CRC32](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/CRC32.html) | [crc](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPOutputStream.html#crc) | CRC-32 of uncompressed data. |

### Inherited Field Summary

From class [java.util.zip.DeflaterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html)

|---|---|---|
| protected byte\[\] | [buf](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html#buf) | Output buffer for writing compressed data. |
| protected [Deflater](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/Deflater.html) | [def](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html#def) | Compressor for this stream. |

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

|---|---|---|
| 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

|---|---|
|   | [GZIPOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPOutputStream.html#GZIPOutputStream(java.io.OutputStream,%20int))([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out, int size) Creates a new output stream with the specified buffer size. |
|   | [GZIPOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPOutputStream.html#GZIPOutputStream(java.io.OutputStream,%20int,%20boolean))([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out, int size, boolean syncFlush) Creates a new output stream with the specified buffer size and flush mode. |
|   | [GZIPOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPOutputStream.html#GZIPOutputStream(java.io.OutputStream))([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out) Creates a new output stream with a default buffer size. |
|   | [GZIPOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPOutputStream.html#GZIPOutputStream(java.io.OutputStream,%20boolean))([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out, boolean syncFlush) Creates a new output stream with a default buffer size and the specified flush mode. |

### Public Method Summary

|---|---|
| void | [finish](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPOutputStream.html#finish())() Finishes writing compressed data to the output stream without closing the underlying stream. |
| synchronized void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPOutputStream.html#write(byte[],%20int,%20int))(byte\[\] buf, int off, int len) Writes array of bytes to the compressed output stream. |

### Inherited Method Summary

From class [java.util.zip.DeflaterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html)

|---|---|
| void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html#close())() Writes remaining compressed data to the output stream and closes the underlying stream. |
| void | [deflate](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html#deflate())() Writes next block of compressed data to the output stream. |
| void | [finish](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html#finish())() Finishes writing compressed data to the output stream without closing the underlying stream. |
| void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html#flush())() Flushes the compressed output stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html#write(byte[],%20int,%20int))(byte\[\] b, int off, int len) Writes an array of bytes to the compressed output stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html#write(int))(int b) Writes a byte to the compressed output stream. |

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

|---|---|
| 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. |

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 [CRC32](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/CRC32.html)
**crc**

CRC-32 of uncompressed data.

## Public Constructors

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

Creates a new output stream with the specified buffer size.

The new output stream instance is created as if by invoking
the 3-argument constructor GZIPOutputStream(out, size, false).

##### Parameters

| out | the output stream |
| size | the output buffer size |
|---|---|

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error has occurred. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `size <= 0` |
|---|---|

#### public
**GZIPOutputStream**
([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out, int size, boolean syncFlush)

Creates a new output stream with the specified buffer size and
flush mode.

##### Parameters

| out | the output stream |
| size | the output buffer size |
| syncFlush | if `true` invocation of the inherited `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html#flush()` method of this instance flushes the compressor with flush mode `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/Deflater.html#SYNC_FLUSH` before flushing the output stream, otherwise only flushes the output stream |
|---|---|

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error has occurred. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `size <= 0` |
|---|---|

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

Creates a new output stream with a default buffer size.

The new output stream instance is created as if by invoking
the 2-argument constructor GZIPOutputStream(out, false).

##### Parameters

| out | the output stream |
|---|---|

##### Throws

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

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

Creates a new output stream with a default buffer size and
the specified flush mode.

##### Parameters

| out | the output stream |
| syncFlush | if `true` invocation of the inherited `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html#flush()` method of this instance flushes the compressor with flush mode `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/Deflater.html#SYNC_FLUSH` before flushing the output stream, otherwise only flushes the output stream |
|---|---|

##### Throws

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

## Public Methods

#### public void
**finish**
()

Finishes writing compressed data to the output stream without closing
the underlying stream. Use this method when applying multiple filters
in succession to the same output stream.

##### Throws

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

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

Writes array of bytes to the compressed output stream. This method
will block until all the bytes are written.

##### Parameters

| buf | the data to be written |
| off | the start offset of the data |
| len | the length of the data |
|---|---|

##### Throws

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