Android examples for java.util.zip:Zip
compress string and return the compressed a string
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPOutputStream; public class Main { public static String compress(String str) throws IOException { if (str == null || str.length() == 0) { return str; }/*w w w. ja va 2s.c om*/ ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(out); gzip.write(str.getBytes()); gzip.close(); return out.toString("ISO-8859-1"); } }