Sample code for 30+ languages & platforms
Java

Ungzip Base64 String

See more Gzip Examples

Suppose you have a gzip in base64 representation that contains a text file, such as XML. This example shows how to decompress and access the string.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkGzip gzip = new CkGzip();

    String gzipBase64 = "H4sIAAAAAAAE ... X6aZjXO3EwAA";

    CkBinData bd = new CkBinData();
    success = bd.AppendEncoded(gzipBase64,"base64");

    success = gzip.UncompressBd(bd);
    if (success != true) {
        System.out.println(gzip.lastErrorText());
        return;
        }

    String strXml = bd.getString("utf-8");
    System.out.println("XML:");
    System.out.println(strXml);
  }
}