Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import java.util.zip.GZIPOutputStream; public class Main { public static byte[] gzip(byte[] data) { byte[] b = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(bos); gzip.write(data); gzip.finish(); gzip.close(); b = bos.toByteArray(); bos.close(); } catch (Exception ex) { ex.printStackTrace(); } return b; } }