Java
Chilkat2 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
import com.chilkatsoft.chilkat2.BinData;
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Gzip;
public class ChilkatExample {
public static void main(String[] args) {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Gzip gzip = new Gzip();
String gzipBase64 = "H4sIAAAAAAAE ... X6aZjXO3EwAA";
BinData bd = new BinData();
bd.appendEncoded(gzipBase64, "base64");
try {
gzip.uncompressBd(bd);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
String strXml = bd.getString("utf-8");
System.out.println("XML:");
System.out.println(strXml);
}
}