Here you can find the source of deflate(byte[] bytes)
public static byte[] deflate(byte[] bytes) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.util.zip.*; public class Main { public static byte[] deflate(byte[] bytes) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DeflaterOutputStream dos = new DeflaterOutputStream(bos, new Deflater(Deflater.DEFAULT_COMPRESSION, true)); dos.write(bytes);/*from w w w. j a v a 2 s .co m*/ dos.close(); return bos.toByteArray(); } }