Gzip
Gzip wraps deflate with a header and a CRC. Select it with Compression.gzip(); Decompressor detects it from its magic number.
Options, each returning a changed copy: level, bufferSize, deflateStrategy, fileName, comment, modificationTime, operatingSystem, fileNameCharset and decompressConcatenated.
Decompressor enforces the default limits; a stream that expands past a ratio of 100 after the first MiB throws LimitExceededException.
Example Usage
Gzip Compression
Compression gzip = Compression.gzip()
.bufferSize(1024)
.level(9)
.comment("comment")
.deflateStrategy(DeflateStrategy.HUFFMAN_ONLY)
.operatingSystem(0);
try (Compressor compressor =
Compressor.builder(Path.of("example.gz"), gzip).build()) {
compressor.write(Path.of("path/to/file.txt"));
}
Gzip Decompression
try (Decompressor decompressor =
Decompressor.builder(Path.of("example.gz")).build()) {
decompressor.write(Path.of("path/to/file.txt"));
}