Package net.jpountz.lz4
LZ4 compression. The entry point of the API is the
LZ4Factory
class, which gives access to
compressors
and
decompressors
.
Sample usage:
LZ4Factory factory = LZ4Factory.fastestInstance(); byte[] data = "12345345234572".getBytes("UTF-8"); final int decompressedLength = data.length; // compress data LZ4Compressor compressor = factory.fastCompressor(); int maxCompressedLength = compressor.maxCompressedLength(decompressedLength); byte[] compressed = new byte[maxCompressedLength]; int compressedLength = compressor.compress(data, 0, decompressedLength, compressed, 0, maxCompressedLength); // decompress data // - method 1: when the decompressed length is known LZ4FastDecompressor decompressor = factory.fastDecompressor(); byte[] restored = new byte[decompressedLength]; int compressedLength2 = decompressor.decompress(compressed, 0, restored, 0, decompressedLength); // compressedLength == compressedLength2 // - method 2: when the compressed length is known (a little slower) // the destination buffer needs to be over-sized LZ4SafeDecompressor decompressor2 = factory.safeDecompressor(); int decompressedLength2 = decompressor2.decompress(compressed, 0, compressedLength, restored, 0); // decompressedLength == decompressedLength2
-
Interface Summary Interface Description LZ4Decompressor Deprecated. UseLZ4FastDecompressor
instead.LZ4UnknownSizeDecompressor Deprecated. UseLZ4SafeDecompressor
instead. -
Class Summary Class Description LZ4BlockInputStream InputStream
implementation to decode data written withLZ4BlockOutputStream
.LZ4BlockOutputStream Streaming LZ4 (not compatible with the LZ4 Frame format).LZ4Compressor LZ4 compressor.LZ4CompressorWithLength Covenience class to include the length of the original decompressed data in the output compressed data, so that the user does not need to save the length at anywhere else.LZ4DecompressorWithLength Convenience class to decompress data compressed byLZ4CompressorWithLength
.LZ4Factory Entry point for the LZ4 API.LZ4FastDecompressor LZ4 decompressor that requires the size of the original input to be known.LZ4FrameInputStream Implementation of the v1.5.1 LZ4 Frame format.LZ4FrameOutputStream Implementation of the v1.5.1 LZ4 Frame format.LZ4FrameOutputStream.BD LZ4FrameOutputStream.FLG LZ4SafeDecompressor LZ4 decompressor that requires the size of the compressed data to be known. -
Enum Summary Enum Description LZ4FrameOutputStream.BLOCKSIZE LZ4FrameOutputStream.FLG.Bits -
Exception Summary Exception Description LZ4Exception LZ4 compression or decompression error.