public class Lz4
extends java.lang.Object
Constructor and Description |
---|
Lz4() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
compress(byte[] bytes)
Compress an array of bytes using the high compressor.
|
static byte[] |
compress(net.jpountz.lz4.LZ4Compressor compressor,
byte[] bytes)
Compress an array of bytes using the provided compressor.
|
static void |
compressFile(java.nio.file.Path from,
java.nio.file.Path to)
Compresses a file on disk and writes the compressed file back to disk.
|
static int |
decodeUncompressedSize(byte[] bytes)
Converts 4-bytes that represent the size of the original uncompressed byte array into a single integer.
|
static byte[] |
decompressFast(byte[] bytes)
Decompresses an array of bytes using the fast decompressor.
|
static void |
decompressFileFast(java.nio.file.Path from,
java.nio.file.Path to)
Decompresses a file on disk using the fast decompressor and writes the decompressed file back to disk.
|
static void |
decompressFileSafe(java.nio.file.Path from,
java.nio.file.Path to)
Decompresses a file on disk using the safe decompressor and writes the decompressed file back to disk.
|
static byte[] |
decompressSafe(byte[] bytes)
Decompresses an array of bytes using the safe decompressor.
|
static byte[] |
encodeUncompressedSize(int size)
Converts an integer which represents the size of an original uncompressed file in bytes into 4 bytes which are
prepended to a compressed LZ4 byte array.
|
static net.jpountz.lz4.LZ4Factory |
getLz4Factory()
Returns a singleton instance of an Lz4 factory.
|
static net.jpountz.lz4.LZ4Compressor |
getLz4FastCompressor()
Returns a singleton instance of an Lz4 fast compressor.
|
static net.jpountz.lz4.LZ4FastDecompressor |
getLz4FastDecompressor()
Returns a singleton instance of an Lz4 fast decompressor.
|
static net.jpountz.lz4.LZ4Compressor |
getLz4HighCompressor()
Returns a singleton instance of an Lz4 high compressor.
|
static net.jpountz.lz4.LZ4SafeDecompressor |
getLz4SafeDecompressor()
Returns a singleton instance of an Lz4 safe decompressor.
|
public static net.jpountz.lz4.LZ4Factory getLz4Factory()
public static net.jpountz.lz4.LZ4Compressor getLz4HighCompressor()
public static net.jpountz.lz4.LZ4Compressor getLz4FastCompressor()
public static net.jpountz.lz4.LZ4FastDecompressor getLz4FastDecompressor()
public static net.jpountz.lz4.LZ4SafeDecompressor getLz4SafeDecompressor()
public static byte[] compress(byte[] bytes)
bytes
- An array of bytes to compress.public static byte[] compress(net.jpountz.lz4.LZ4Compressor compressor, byte[] bytes)
compressor
- An instance of an Lz4 compressor.bytes
- An array of bytes to compress.public static void compressFile(java.nio.file.Path from, java.nio.file.Path to) throws java.io.IOException
from
- The file to compress.to
- The location of the resulting compressed file where the first 4 bytes represent the size of the
original uncompressed file.java.io.IOException
- If the source file DNE or the result file can not be written.public static void decompressFileFast(java.nio.file.Path from, java.nio.file.Path to) throws java.io.IOException
from
- The compressed file to decompress.to
- The location of the resulting decompressed file.java.io.IOException
- If the source file DNE or the result file can not be written.public static void decompressFileSafe(java.nio.file.Path from, java.nio.file.Path to) throws java.io.IOException
from
- The compressed file to decompress.to
- The location of the resulting decompressed file.java.io.IOException
- If the source file DNE or the result file can not be written.public static byte[] decompressFast(byte[] bytes)
bytes
- An array of bytes to decompress where the first 4 bytes represent the size of the original
uncompressed byte array.public static byte[] decompressSafe(byte[] bytes)
bytes
- An array of bytes to decompress where the first 4 bytes represent the size of the original
uncompressed byte array.public static int decodeUncompressedSize(byte[] bytes)
bytes
- The 4 bytes that represent the size of the original uncompressed byte array.public static byte[] encodeUncompressedSize(int size)
size
- The size of the original uncompressed byte array.