Class LZBCompression

java.lang.Object
com.github.tommyettinger.textra.utils.LZBCompression

public final class LZBCompression extends Object
Compresses Strings to byte arrays using a type of LZ-compression. This is the counterpart to 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 Details

    • compressToBytes

      public static byte[] compressToBytes(String uncompressedStr)
      Compresses a String using LZB compression and returns it as a byte array. You can read the byte array this produces with LZBDecompression.decompressFromBytes(byte[]), which will produce the original String. This does very well if uncompressedStr 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

      public static com.badlogic.gdx.utils.ByteArray compressToByteArray(String uncompressedStr)
      Compresses a String using LZB and returns it as a libGDX ByteArray. You can read the byte array this produces with LZBDecompression.decompressFromByteArray(ByteArray), which will produce the original String. This does very well if uncompressedStr 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