public class CompressionUtils
extends java.lang.Object
CompressionUtils
that encapsulates common compression calls and operations
in one spot.Constructor and Description |
---|
CompressionUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
compress(java.lang.String srcTxt)
Use ZipOutputStream to zip text to byte array, then convert
byte array to base64 string, so it can be transferred via http request.
|
static java.lang.String |
decodeByteArrayToString(byte[] bytes)
Decode the byte[] in base64 to a string.
|
static java.lang.String |
decompress(java.lang.String zippedBase64Str)
First decode base64 String to byte array, then use ZipInputStream to revert the byte array to a
string.
|
static java.lang.String |
deflate(byte[] bytes)
Deflate the given bytes using zlib.
|
static java.lang.String |
deflate(java.lang.String data)
Deflate the given string via a
Deflater . |
static java.lang.String |
inflate(byte[] bytes)
Inflate the given byte array by
INFLATED_ARRAY_LENGTH . |
public static java.lang.String deflate(byte[] bytes)
bytes
- the bytespublic static java.lang.String deflate(java.lang.String data)
Deflater
.data
- the datapublic static java.lang.String inflate(byte[] bytes)
INFLATED_ARRAY_LENGTH
.bytes
- the bytesUTF-8
encodingpublic static java.lang.String decompress(java.lang.String zippedBase64Str)
zippedBase64Str
- the zipped base 64 strpublic static java.lang.String compress(java.lang.String srcTxt)
srcTxt
- the src txtpublic static java.lang.String decodeByteArrayToString(byte[] bytes)
bytes
- the data to encode