public class GzipWriter extends java.lang.Object implements java.io.Closeable
| Modifier and Type | Class and Description |
|---|---|
protected static class |
GzipWriter.GzipEntryOutputStream
OutputStream to GZip compress data in a controlled fashion. |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
bIsCompliant
Compliance status for records parsed up to now.
|
protected int |
compressionLevel
Compression level to be used by deflater.
|
protected java.util.zip.CRC32 |
crc
Checksum object used to calculate CRC16 and CRC32 values.
|
protected java.util.zip.Deflater |
def
Deflater used to compress GZip entries.
|
static int |
DEFAULT_INPUT_BUFFER_SIZE
Default input buffer size.
|
protected GzipEntry |
gzipEntry
Current GZip entry object.
|
protected byte[] |
inputBytes
Input buffer used to feed the deflater.
|
protected ISO8859_1 |
iso8859_1
ISO-8859-1 validating de-/encoder.
|
protected java.io.OutputStream |
out
Output stream for GZip (multi-part) file.
|
| Constructor and Description |
|---|
GzipWriter(java.io.OutputStream out)
Construct a GZip writer with a default input buffer size of 1024.
|
GzipWriter(java.io.OutputStream out,
int buffer_size)
Construct a GZip writer with the specified input buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Release resources associated with this writer.
|
int |
getCompressionLevel()
Returns current compression level used by deflater.
|
boolean |
isCompliant()
Returns a boolean indicating whether all entries written so far are compliant.
|
protected int |
readCompressed(java.nio.ByteBuffer bb,
byte[] b,
int off,
int len,
boolean bFinish)
Read data from
ByteBuffer and fill buffer with compressed
data. |
protected int |
readCompressed(java.io.InputStream in,
byte[] b,
int off,
int len)
Read data from input stream and fill buffer with compressed data.
|
void |
setCompressionLevel(int compressionLevel)
Set compression level used by deflater.
|
void |
writeEntryHeader(GzipEntry entry)
Write a GZip entry header and prepare for compressing input data.
|
protected void |
writeTrailer(GzipEntry entry)
Computes the CRC32 and iSize values and then writes the GZip entry trailer.
|
public static final int DEFAULT_INPUT_BUFFER_SIZE
protected java.io.OutputStream out
protected java.util.zip.Deflater def
protected java.util.zip.CRC32 crc
protected byte[] inputBytes
protected int compressionLevel
protected boolean bIsCompliant
public GzipWriter(java.io.OutputStream out)
out - output stream of GZip filepublic GzipWriter(java.io.OutputStream out, int buffer_size)
out - output stream of GZip filebuffer_size - input buffer size to usepublic void close() throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException - if an I/O error occurs while closing writerpublic boolean isCompliant()
public void setCompressionLevel(int compressionLevel)
compressionLevel - compression leveljava.lang.IllegalArgumentException - If CompressionLevel is invalidpublic int getCompressionLevel()
public void writeEntryHeader(GzipEntry entry) throws java.io.IOException
entry - GZip entry objectjava.io.IOException - if an I/O error occurs while writing headerprotected void writeTrailer(GzipEntry entry) throws java.io.IOException
entry - GZip entry objectjava.io.IOException - if an I/O error occurs while writing trailerprotected int readCompressed(java.io.InputStream in, byte[] b, int off, int len) throws java.util.zip.DataFormatException, java.io.IOException
in - input stream with uncompressed datab - compressed data bufferoff - offset in compressed data bufferlen - length of compressed data to readjava.util.zip.DataFormatException - if an error occurs in deflaterjava.io.IOException - if an I/O error occurs while compressingprotected int readCompressed(java.nio.ByteBuffer bb, byte[] b, int off, int len, boolean bFinish) throws java.util.zip.DataFormatException, java.io.IOException
ByteBuffer and fill buffer with compressed
data.bb - ByteBuffer with uncompressed datab - compressed data bufferoff - offset in compressed data bufferlen - length of compressed data to readbFinish - boolean indicating that there is no more data to compressjava.util.zip.DataFormatException - if an error occurs in deflaterjava.io.IOException - if an error occurs while compressingCopyright © 2011–2023. All rights reserved.