snappy-android is a android port of the snappy http://code.google.com/p/snappy/, a fast C++ compresser/decompresser developed by Google.
Using JCenter:
repositories {
jcenter()
}
dependencies {
compile 'com.jiechic.android.library:snappy-android:1.1.7'
}
First, import com.jiechic.library.android.snappy.Snappy
in your Java code:
import com.jiechic.library.android.snappy.Snappy;
Then use Snappy.compress(byte[])
and Snappy.uncompress(byte[])
:
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of "
+ "Snappy, a fast compresser/decompresser.";
byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
byte[] uncompressed = Snappy.uncompress(compressed);
String result = new String(uncompressed, "UTF-8");
System.out.println(result);
In addition, high-level methods (Snappy.compress(String)
, Snappy.compress(float[] ..)
etc. ) and low-level ones (e.g. Snappy.rawCompress(.. )
, Snappy.rawUncompress(..)
, etc.), which minimize memory copies, can be used.
Snappy-Android is developed by Jiechic. Twitter @jiechic