Here you can find the source of zip(byte[] datas)
public static byte[] zip(byte[] datas) throws IOException
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.DeflaterOutputStream; public class Main { public static byte[] zip(byte[] datas) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); DeflaterOutputStream dos = new DeflaterOutputStream(out); dos.write(datas);/*from ww w . j a va2 s. c o m*/ dos.close(); return out.toByteArray(); } }