You are viewing the documentation for a prerelease version.
View Latest
LZMA
Here is a simple example of how to use LZMA compression. It requires org.tukaani:xz at runtime, the same library the XZ formats use; see Additional Formats.
Example Usage
LZMA Compression
try (LZMACompressor lzmaCompressor =
LZMACompressor.builder(Path.of("example.lzma")).build()) {
lzmaCompressor.write(Path.of("path/to/file.txt"));
}
LZMA Decompression
try (LZMADecompressor lzmaDecompressor = LZMADecompressor.builder(Path.of("example.lzma"))
.compressorInputStreamBuilder()
.setMemoryLimitInKb(65536)
.parentBuilder()
.build()) {
lzmaDecompressor.write(Path.of("path/to/file.txt"));
}
Want to help? Learn how to contribute to the Compress4J docs ›