Here you can find the source of deflate(byte[] buf)
static byte[] deflate(byte[] buf)
//package com.java2s; import java.util.zip.*; import java.io.*; public class Main { static byte[] deflate(byte[] buf) { try {/* w w w .j av a2s. c om*/ ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length); DeflaterOutputStream dos = new DeflaterOutputStream(baos); dos.write(buf, 0, buf.length); dos.close(); return baos.toByteArray(); } catch (IOException e) { return null; } } }