Here you can find the source of zip(byte[] input)
public static byte[] zip(byte[] input)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPOutputStream; public class Main { public static byte[] zip(byte[] input) { if (input == null || input.length == 0) { return input; }//from ww w .j a va 2s .c o m try { ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(out); gzip.write(input); gzip.close(); return out.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } } }