You are viewing the documentation for a prerelease version. View Latest

Zstandard

Here is a simple example of how to use Zstandard compression. It requires com.github.luben:zstd-jni at runtime; see Additional Formats.

Example Usage

Zstandard Compression
try (ZstdCompressor zstdCompressor = ZstdCompressor.builder(Path.of("example.zst"))
        .compressorOutputStreamBuilder()
        .level(6)
        .parentBuilder()
        .build()) {
    zstdCompressor.write(Path.of("path/to/file.txt"));
}
Zstandard Decompression
try (ZstdDecompressor zstdDecompressor =
        ZstdDecompressor.builder(Path.of("example.zst")).build()) {
    zstdDecompressor.write(Path.of("path/to/file.txt"));
}