Top Description Fields Constructors Methods
java.util.zip

public Class GZIPOutputStream

extends DeflaterOutputStream
Class Inheritance
Imports
java.io.OutputStream, .IOException

This class implements a stream filter for writing compressed data in the GZIP file format.
Author
David Connelly
Since
1.1

Field Summary

Modifier and TypeField and Description
protected CRC32
crc

CRC-32 of uncompressed data.

private static final int
private static final byte
private static final int
Inherited from java.util.zip.DeflaterOutputStream:
bufdefusesDefaultDeflater

Constructor Summary

AccessConstructor and Description
public
GZIPOutputStream(OutputStream
the output stream
out
,
int
the output buffer size
size
)

Creates a new output stream with the specified buffer size.

public
GZIPOutputStream(OutputStream
the output stream
out
,
int
the output buffer size
size
,
boolean
if true invocation of the inherited flush() method of this instance flushes the compressor with flush mode Deflater#SYNC_FLUSH before flushing the output stream, otherwise only flushes the output stream
syncFlush
)

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

public
GZIPOutputStream(OutputStream
the output stream
out
)

Creates a new output stream with a default buffer size.

public
GZIPOutputStream(OutputStream
the output stream
out
,
boolean
if true invocation of the inherited flush() method of this instance flushes the compressor with flush mode Deflater#SYNC_FLUSH before flushing the output stream, otherwise only flushes the output stream
syncFlush
)

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

Method Summary

Modifier and TypeMethod and Description
public void
finish()

Overrides java.util.zip.DeflaterOutputStream.finish.

Finishes writing compressed data to the output stream without closing the underlying stream.

public synchronized void
write(byte[]
the data to be written
buf
,
int
the start offset of the data
off
,
int
the length of the data
len
)

Overrides java.util.zip.DeflaterOutputStream.write.

Writes array of bytes to the compressed output stream.

private void
private void
writeInt(int i, byte[] buf, int offset)

private void
writeShort(int s, byte[] buf, int offset)

private void
writeTrailer(byte[] buf, int offset)

Inherited from java.util.zip.DeflaterOutputStream:
closedeflateflushwrite

Field Detail

crcback to summary
protected CRC32 crc

CRC-32 of uncompressed data.

GZIP_MAGICback to summary
private static final int GZIP_MAGIC
OS_UNKNOWNback to summary
private static final byte OS_UNKNOWN
TRAILER_SIZEback to summary
private static final int TRAILER_SIZE

Constructor Detail

GZIPOutputStreamback to summary
public GZIPOutputStream(OutputStream out, int size) throws IOException

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

the output stream

size:int

the output buffer size

Exceptions
IOException:
If an I/O error has occurred.
IllegalArgumentException:
if size <= 0
GZIPOutputStreamback to summary
public GZIPOutputStream(OutputStream out, int size, boolean syncFlush) throws IOException

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

Parameters
out:OutputStream

the output stream

size:int

the output buffer size

syncFlush:boolean

if true invocation of the inherited flush() method of this instance flushes the compressor with flush mode Deflater#SYNC_FLUSH before flushing the output stream, otherwise only flushes the output stream

Exceptions
IOException:
If an I/O error has occurred.
IllegalArgumentException:
if size <= 0
Since
1.7
GZIPOutputStreamback to summary
public GZIPOutputStream(OutputStream out) throws IOException

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

the output stream

Exceptions
IOException:
If an I/O error has occurred.
GZIPOutputStreamback to summary
public GZIPOutputStream(OutputStream out, boolean syncFlush) throws IOException

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

Parameters
out:OutputStream

the output stream

syncFlush:boolean

if true invocation of the inherited flush() method of this instance flushes the compressor with flush mode Deflater#SYNC_FLUSH before flushing the output stream, otherwise only flushes the output stream

Exceptions
IOException:
If an I/O error has occurred.
Since
1.7

Method Detail

finishback to summary
public void finish() throws IOException

Overrides java.util.zip.DeflaterOutputStream.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.

Exceptions
IOException:
if an I/O error has occurred
writeback to summary
public synchronized void write(byte[] buf, int off, int len) throws IOException

Overrides java.util.zip.DeflaterOutputStream.write.

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

Parameters
buf:byte[]

the data to be written

off:int

the start offset of the data

len:int

the length of the data

Exceptions
IOException:
If an I/O error has occurred.
writeHeaderback to summary
private void writeHeader() throws IOException
writeIntback to summary
private void writeInt(int i, byte[] buf, int offset) throws IOException
writeShortback to summary
private void writeShort(int s, byte[] buf, int offset) throws IOException
writeTrailerback to summary
private void writeTrailer(byte[] buf, int offset) throws IOException