LZMA

Select LZMA with Compression.lzma(). It requires org.tukaani:xz at runtime, the same library XZ uses; see Additional Formats.

LZMA streams have no magic number, so Decompressor and the tar extractor never detect them: pass Compression.lzma() explicitly. A stream with no detectable signature passes through unchanged, so Decompressor.builder(p) on LZMA data returns the compressed bytes: use Decompressor.builder(p, Compression.lzma()). The one option, memoryLimitKiB, caps the memory a read may use (default 256 MiB).

Decompressor enforces the default limits; a stream that expands past a ratio of 100 after the first MiB throws LimitExceededException.

Example Usage

LZMA Compression
try (Compressor compressor =
        Compressor.builder(Path.of("example.lzma"), Compression.lzma()).build()) {
    compressor.write(Path.of("path/to/file.txt"));
}
LZMA Decompression
Compression lzma = Compression.lzma().memoryLimitKiB(65536);
try (Decompressor decompressor =
        Decompressor.builder(Path.of("example.lzma"), lzma).build()) {
    decompressor.write(Path.of("path/to/file.txt"));
}