Package kala.compress.compressors.gzip
Class GzipCompressorOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
kala.compress.compressors.CompressorOutputStream<OutputStream>
kala.compress.compressors.gzip.GzipCompressorOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Compressed output stream using the gzip format. This implementation improves over the standard
GZIPOutputStream class by allowing the configuration
of the compression level and the header metadata (file name, comment, modification time, operating system and extra flags).- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanIndicates if the stream has been closedprivate final CRC32The checksum of the uncompressed dataprivate final byte[]The buffer receiving the compressed data from the deflaterprivate final DeflaterDeflater used to compress the dataprivate static final intHeader flag indicating a comment follows the headerprivate static final intHeader flag indicating an EXTRA subfields collection follows the headerprivate static final intHeader flag indicating a file name follows the headerFields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
ConstructorsConstructorDescriptionCreates a gzip compressed output stream with the default parameters.GzipCompressorOutputStream(OutputStream out, GzipParameters parameters) Creates a gzip compressed output stream with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()private voiddeflate()voidfinish()Finishes writing compressed data to the underlying stream without closing it.voidwrite(byte[] buffer) voidwrite(byte[] buffer, int offset, int length) voidwrite(int b) private voidWrites a NUL-terminated String encoded with thecharset.private voidwriteHeader(GzipParameters parameters) private voidMethods inherited from class kala.compress.compressors.CompressorOutputStream
outMethods inherited from class java.io.FilterOutputStream
flushMethods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
FEXTRA
private static final int FEXTRAHeader flag indicating an EXTRA subfields collection follows the header- See Also:
-
FNAME
private static final int FNAMEHeader flag indicating a file name follows the header- See Also:
-
FCOMMENT
private static final int FCOMMENTHeader flag indicating a comment follows the header- See Also:
-
deflater
Deflater used to compress the data -
deflateBuffer
private final byte[] deflateBufferThe buffer receiving the compressed data from the deflater -
closed
private boolean closedIndicates if the stream has been closed -
crc
The checksum of the uncompressed data
-
-
Constructor Details
-
GzipCompressorOutputStream
Creates a gzip compressed output stream with the default parameters.- Parameters:
out- the stream to compress to- Throws:
IOException- if writing fails
-
GzipCompressorOutputStream
Creates a gzip compressed output stream with the specified parameters.- Parameters:
out- the stream to compress toparameters- the parameters to use- Throws:
IOException- if writing fails- Since:
- 1.7
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
deflate
- Throws:
IOException
-
finish
Finishes writing compressed data to the underlying stream without closing it.- Throws:
IOException- on error- Since:
- 1.7
-
write
- Overrides:
writein classFilterOutputStream- Throws:
IOException- Since:
- 1.1
-
write
- Overrides:
writein classFilterOutputStream- Throws:
IOException- Since:
- 1.1
-
write
- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
Writes a NUL-terminated String encoded with thecharset.- Parameters:
value- The String to write.charset- Specifies the Charset to use.- Throws:
IOException- if an I/O error occurs.
-
writeHeader
- Throws:
IOException
-
writeTrailer
- Throws:
IOException
-