public class GzipCompressorOutputStream extends CompressorOutputStream
GZIPOutputStream
class by allowing
the configuration of the compression level and the header metadata (filename,
comment, modification time, operating system and extra flags).Modifier and Type | Field and Description |
---|---|
private boolean |
closed
Indicates if the stream has been closed
|
private java.util.zip.CRC32 |
crc
The checksum of the uncompressed data
|
private byte[] |
deflateBuffer
The buffer receiving the compressed data from the deflater
|
private java.util.zip.Deflater |
deflater
Deflater used to compress the data
|
private static int |
FCOMMENT
Header flag indicating a comment follows the header
|
private static int |
FNAME
Header flag indicating a file name follows the header
|
private java.io.OutputStream |
out
The underlying stream
|
Constructor and Description |
---|
GzipCompressorOutputStream(java.io.OutputStream out)
Creates a gzip compressed output stream with the default parameters.
|
GzipCompressorOutputStream(java.io.OutputStream out,
GzipParameters parameters)
Creates a gzip compressed output stream with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
private void |
deflate() |
void |
finish()
Finishes writing compressed data to the underlying stream without closing it.
|
void |
flush() |
void |
write(byte[] buffer) |
void |
write(byte[] buffer,
int offset,
int length) |
void |
write(int b) |
private void |
writeHeader(GzipParameters parameters) |
private void |
writeTrailer() |
private static final int FNAME
private static final int FCOMMENT
private final java.io.OutputStream out
private final java.util.zip.Deflater deflater
private final byte[] deflateBuffer
private boolean closed
private final java.util.zip.CRC32 crc
public GzipCompressorOutputStream(java.io.OutputStream out) throws java.io.IOException
out
- the stream to compress tojava.io.IOException
- if writing failspublic GzipCompressorOutputStream(java.io.OutputStream out, GzipParameters parameters) throws java.io.IOException
out
- the stream to compress toparameters
- the parameters to usejava.io.IOException
- if writing failsprivate void writeHeader(GzipParameters parameters) throws java.io.IOException
java.io.IOException
private void writeTrailer() throws java.io.IOException
java.io.IOException
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] buffer) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] buffer, int offset, int length) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
private void deflate() throws java.io.IOException
java.io.IOException
public void finish() throws java.io.IOException
java.io.IOException
- on errorpublic void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException