Here you can find the source of gzipString(String src, byte default_value[])
static public byte[] gzipString(String src, byte default_value[])
//package com.java2s; //License from project: BSD License import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.Charset; import java.util.zip.GZIPOutputStream; import com.amazonaws.util.IOUtils; public class Main { static private Charset utf8 = Charset.forName("UTF-8"); static public byte[] gzipString(String src, byte default_value[]) { if (src == null) return default_value; return gzip(src.getBytes(utf8), default_value); }/*from w w w. j a va2s . com*/ static public byte[] gzip(byte src[], byte default_value[]) { try { if (src == null) return default_value; ByteArrayOutputStream out_raw = new ByteArrayOutputStream(); GZIPOutputStream out = new GZIPOutputStream(out_raw); ByteArrayInputStream in = new ByteArrayInputStream(src); IOUtils.copy(in, out); in.close(); out.close(); return out_raw.toByteArray(); } catch (Exception e) { return default_value; } } }