java.lang.Object | ||||
↳ | java.io.OutputStream | |||
↳ | java.io.FilterOutputStream | |||
↳ | java.util.zip.DeflaterOutputStream | |||
↳ | java.util.zip.GZIPOutputStream |
The GZIPOutputStream
class is used to write data to a stream in the
GZIP storage format.
Using GZIPOutputStream
is a little easier than ZipOutputStream
because GZIP is only for compression, and is not a container for multiple files.
This code creates a GZIP stream, similar to the gzip(1)
utility.
OutputStream os = ... byte[] bytes = ... GZIPOutputStream zos = new GZIPOutputStream(new BufferedOutputStream(os)); try { zos.write(bytes); } finally { zos.close(); }
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
crc | The checksum algorithm used when treating uncompressed data. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.zip.DeflaterOutputStream
| |||||||||||
From class
java.io.FilterOutputStream
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct a new
GZIPOutputStream to write data in GZIP format to
the underlying stream. | |||||||||||
Construct a new
GZIPOutputStream to write data in GZIP format to
the underlying stream. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Indicates to the stream that all data has been written out, and any GZIP
terminal data can now be written.
| |||||||||||
Write up to nbytes of data from the given buffer, starting at offset off,
to the underlying stream in GZIP format.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.zip.DeflaterOutputStream
| |||||||||||
From class
java.io.FilterOutputStream
| |||||||||||
From class
java.io.OutputStream
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.io.Closeable
| |||||||||||
From interface
java.io.Flushable
|
The checksum algorithm used when treating uncompressed data.
Construct a new GZIPOutputStream
to write data in GZIP format to
the underlying stream.
os | the OutputStream to write data to. |
---|
IOException | if an IOException occurs.
|
---|
Construct a new GZIPOutputStream
to write data in GZIP format to
the underlying stream. Set the internal compression buffer to size
size
.
os | the OutputStream to write to. |
---|---|
size | the internal buffer size. |
IOException | if an IOException occurs.
|
---|
Indicates to the stream that all data has been written out, and any GZIP terminal data can now be written.
IOException | if an IOException occurs.
|
---|
Write up to nbytes of data from the given buffer, starting at offset off, to the underlying stream in GZIP format.
buffer | the buffer to write. |
---|---|
off | the index of the first byte in buffer to write. |
nbytes | the number of bytes in buffer to write. |
IOException |
---|