Usage
First, import org. in your Java code:
Then use
import org.xerial.snappy.Snappy;
org. and org.:
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.
| Modifier and Type | Interface and Description |
|---|---|
| public interface | SnappyApi
Snappy compressor/decompressor interface. |
| Modifier and Type | Class and Description |
|---|---|
| public class | |
| public class | BitShuffleNative
JNI interfaces of the |
| public class | OSInfo
Provides OS name and architecture name. |
| public class | PureJavaCrc32C
A pure-java implementation of the CRC32 checksum that uses the CRC32-C polynomial, the same polynomial used by iSCSI and implemented on many Intel chipsets supporting SSE4.2. |
| public class | Snappy
Snappy API for data compression/decompression Note if the native libraries cannot be loaded, an ExceptionInInitializerError will be thrown at first use of this class. |
| public class | SnappyBundleActivator
OSGi bundle entry point |
| public class | SnappyCodec
Preamble header for |
| public class | SnappyError
Used when serious errors (unchecked exception) are observed. |
| public class | SnappyException
Deprecated
Snappy-java now uses Exception in snappy-java
IOException
|
| pack-priv class | SnappyFramed
Constants and utilities for implementing x-snappy-framed. |
| public class | SnappyFramedInputStream
Implements the x-snappy-framed as an |
| public class | SnappyFramedOutputStream
Implements the x-snappy-framed as an |
| public class | |
| public class | SnappyInputStream
A stream filter for reading data compressed by |
| public class | SnappyIOException
Enhanced IOException with SnappyErrorCode |
| public class | SnappyLoader
Internal only - Do not use this class. |
| public class | SnappyNative
JNI interface of the |
| public class | SnappyOutputStream
This class implements a stream filter for writing compressed data using Snappy. |
| Modifier and Type | Enum and Description |
|---|---|
| public enum | BitShuffleType
Type codes used in ByteBuffer based BitShuffle APIs |
| public enum | SnappyErrorCode
Error codes of snappy-java |