congmo / compress

Basic LZF codec, compatible with standard C LZF package

Home Page:http://www.ning.com/code/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ning-Compress

Overview

Ning-compress is a Java library for encoding and decoding data in LZF format, written by Tatu Saloranta (tatu.saloranta@iki.fi)

Data format and algorithm based on original LZF library by Marc A Lehmann. See LZF Format for full description.

Format differs slightly from some other adaptations, such as one used by H2 database project (by Thomas Mueller); although internal block compression structure is the same, block identifiers differ. This package uses the original LZF identifiers to be 100% compatible with existing command-line lzf tool(s).

LZF alfgorithm itself is optimized for speed, with somewhat more modest compression: compared to Deflate (algorithm gzip uses) LZF can be 5-6 times as fast to compress, and twice as fast to decompress.

Usage

See Wiki for more details; here's a "TL;DNR" version.

Both compression and decompression can be done either by streaming approach:

InputStream in = new LZFInputStream(new FileInputStream("data.lzf"));
OutputStream out = new LZFOutputStream(new FileOutputStream("results.lzf"));
InputStream compIn = new LZFCompressingInputStream(new FileInputStream("stuff.txt"));

or by block operation:

byte[] compressed = LZFEncoder.encode(uncompressedData);
byte[] uncompressed = LZFDecoder.decode(compressedData);

and you can even use the LZF jar as a command-line tool (it has manifest that points to 'com.ning.compress.lzf.LZF' as the class having main() method to call), like so:

java -jar compress-lzf-1.0.0.jar

(which will display necessary usage arguments for -c(ompressing) or -d(ecompressing) files.

Related

Check out jvm-compress-benchmark for comparison of space- and time-efficiency of this LZF implementation, relative other available Java-accessible compression libraries.

More

Project Wiki.

About

Basic LZF codec, compatible with standard C LZF package

http://www.ning.com/code/

License:Other