Here you can find the source of deflateBuffer(byte[] uncompressedBuffer)
private static byte[] deflateBuffer(byte[] uncompressedBuffer) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.DeflaterOutputStream; public class Main { private static byte[] deflateBuffer(byte[] uncompressedBuffer) throws IOException { final DeflaterOutputStream deflateStream = new DeflaterOutputStream(new ByteArrayOutputStream()); deflateStream.write(uncompressedBuffer, 0, uncompressedBuffer.length); deflateStream.close();// w w w . j av a 2 s. c o m return uncompressedBuffer; } }