Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
org.xerial.snappy.Snappy Example
How to use org.xerial.snappy.Snappy class?
✍: FYIcenter.com
org.xerial.snappy.Snappy class allows you to compress and decompress byte arrays.
Here is an example Java program, HelloSnappy.java:
// HelloSnappy.java
// Copyright (c) FYIcenter.com
import org.xerial.snappy.Snappy;
public class HelloSnappy {
public static void main(String[] args) throws Exception {
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper"
+ " of Snappy, a fast compresser/decompresser.";
byte[] original = input.getBytes("UTF-8");
byte[] compressed = Snappy.compress(original);
byte[] uncompressed = Snappy.uncompress(compressed);
String result = new String(uncompressed, "UTF-8");
System.out.println(result);
}
}
Run this Java program with the Snappy-Java JAR file:
fyicenter$ java -cp snappy-java-1.1.8.4.jar HelloSnappy.java Hello snappy-java! Snappy-java is a JNI-based wrapper of Snappy, a fast compresser/decompresser.
The Java program compress and decompress a message correctly.
2021-08-01, ∼1136🔥, 0💬
Popular Posts:
JDK 11 jdk.jdi.jmod is the JMOD file for JDK 11 JDI (Java Debug Interface) tool. JDK 11 JDI tool com...
JRE 8 deploy.jar is the JAR file for JRE 8 Java Control Panel and other deploy tools. JRE (Java Runt...
JDK 17 java.compiler.jmod is the JMOD file for JDK 17 Compiler module. JDK 17 Compiler module compil...
JDK 11 java.base.jmod is the JMOD file for JDK 11 Base module. JDK 11 Base module compiled class fil...
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java"....