You are viewing the documentation for a prerelease version.
View Latest
XZ
Here is a simple example of how to use xz compression. It requires org.tukaani:xz at runtime; see Additional Formats.
Example Usage
XZ Compression
try (XZCompressor xzCompressor = XZCompressor.builder(Path.of("example.xz"))
.compressorOutputStreamBuilder()
.preset(6)
.parentBuilder()
.build()) {
xzCompressor.write(Path.of("path/to/file.txt"));
}
XZ Decompression
try (XZDecompressor xzDecompressor = XZDecompressor.builder(Path.of("example.xz"))
.compressorInputStreamBuilder()
.setDecompressConcatenated(true)
.parentBuilder()
.build()) {
xzDecompressor.write(Path.of("path/to/file.txt"));
}
Want to help? Learn how to contribute to the Compress4J docs ›