Class LZ4BlockOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class LZ4BlockOutputStream extends FilterOutputStream
Streaming LZ4 (not compatible with the LZ4 Frame format). This class compresses data into fixed-size blocks of compressed data. This class uses its own format and is not compatible with the LZ4 Frame format. For interoperability with other LZ4 tools, use LZ4FrameOutputStream, which is compatible with the LZ4 Frame format. This class remains for backward compatibility.

Each block starts with a header made of the magic bytes "LZ4Block", a token byte, the compressed length, the decompressed length and a checksum of the decompressed data (all three as 32-bit little-endian integers), followed by the block data. The high nibble of the token is the compression method (0x10 for raw, 0x20 for LZ4) and the low nibble is the block size exponent, max(0, ceil(log2(blockSize)) - 10). When the default checksum is used, the checksum field is the XXHash32 (seed 0x9747b28c) of the uncompressed block, masked to its low 28 bits (see StreamingXXHash32.asChecksum()). The exception is the end-of-stream block written by finish(), which is a raw block whose lengths and checksum are all 0.

See Also: