|
Chapter 18 The java.util.zip Package |
|
GZIPOutputStream
Name
GZIPOutputStream
- Class Name:
-
java.util.zip.GZIPOutputStream
- Superclass:
-
java.util.zip.DeflaterOutputStream
- Immediate Subclasses:
-
None
- Interfaces Implemented:
-
None
- Availability:
-
New as of JDK 1.1
The GZIPOutputStream class
compresses data using the GZIP format. To use it, simply construct a GZIPOutputStream
that wraps a regular output stream and use the write()
methods to write compressed data.
public class java.util.zip.GZIPOutputStream
extends java.util.zip.DeflaterOutputStream {
// Variables
protected CRC32 crc;
// Constructors
public GZIPOutputStream(OutputStream out);
public GZIPOutputStream(OutputStream out, int size);
// Instance Methods
public void close();
public void finish();
public synchronized void write(byte[] buf, int off, int len);
}
- Description
-
A checksum that is updated with the uncompressed stream data. The checksum
value is written into the GZIP trailer.
- Parameters
-
- out
-
The underlying output stream.
- Throws
-
- IOException
-
If an error occurs while writing the GZIP header.
- Description
-
This constructor creates a GZIPOutputStream
that writes compressed data to the given OutputStream.
The GZIPOutputStream uses a
compression buffer with the default size of 512 bytes.
- Parameters
-
- out
-
The underlying output stream.
- size
-
The size of the output buffer.
- Throws
-
- IOException
-
If an error occurs while writing the GZIP header.
- Description
-
This constructor creates a GZIPOutputStream
that writes compressed data to the given OutputStream.
The GZIPOutputStream uses a
compression buffer of the given size.
- Throws
-
- IOException
-
If any kind of I/O error occurs.
- Overrides
-
DeflaterOutputStream.close()
- Description
-
This method closes the stream and releases any system resources that are associated with it.
- Throws
-
- IOException
-
If any kind of I/O error occurs.
- Overrides
-
DeflaterOutputStream.finish()
- Description
-
This method finishes writing compressed data to the underlying stream without
closing it.
- Parameters
-
- buf
-
An array of bytes to write to the stream.
- off
-
An offset into the byte array.
- len
-
The number of bytes to write.
- Throws
-
- IOException
-
If any kind of I/O error occurs.
- Overrides
-
DeflaterOutputStream.write(byte[], int, int)
- Description
-
This method takes len bytes
from the given buffer, starting at off,
and compresses them. The method then writes the compressed data to the
underlying OutputStream. The
method blocks until all of the bytes have been written.
Deflater,
DeflaterOutputStream,
FilterOutputStream,
IOException,
OutputStream
|
|