Class LZBCompression
java.lang.Object
com.github.tommyettinger.textra.utils.LZBCompression
Compresses Strings to byte arrays using a type of LZ-compression.
This is the counterpart to
This is loosely based on LZ-String. The LZ-String algorithm was formulated by pieroxy. This was loosely based on a port/optimization attempt on another port (to Java), LZString4Java By Rufus Huang.
LZBDecompression
.
This is loosely based on LZ-String. The LZ-String algorithm was formulated by pieroxy. This was loosely based on a port/optimization attempt on another port (to Java), LZString4Java By Rufus Huang.
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.badlogic.gdx.utils.ByteArray
compressToByteArray
(String uncompressedStr) Compresses a String using LZB and returns it as a libGDX ByteArray.static byte[]
compressToBytes
(String uncompressedStr) Compresses a String using LZB compression and returns it as a byte array.
-
Method Details
-
compressToBytes
Compresses a String using LZB compression and returns it as a byte array. You can read the byte array this produces withLZBDecompression.decompressFromBytes(byte[])
, which will produce the original String. This does very well ifuncompressedStr
contains highly repetitive data, and fairly well in some cases where it doesn't.- Parameters:
uncompressedStr
- a String that you want to compress- Returns:
- a byte array containing the compressed data for
uncompressedStr
-
compressToByteArray
Compresses a String using LZB and returns it as a libGDX ByteArray. You can read the byte array this produces withLZBDecompression.decompressFromByteArray(ByteArray)
, which will produce the original String. This does very well ifuncompressedStr
contains highly repetitive data, and fairly well in some cases where it doesn't.- Parameters:
uncompressedStr
- a String that you want to compress- Returns:
- a libGDX ByteArray containing the compressed data for
uncompressedStr
-