Here you can find the source of deflater(final byte[] inputByte)
public static byte[] deflater(final byte[] inputByte) throws IOException
//package com.java2s; /**/* w w w. j a va 2s . com*/ * * Licensed Property to China UnionPay Co., Ltd. * * (C) Copyright of China UnionPay Co., Ltd. 2010 * All Rights Reserved. * * * Modification History: * ============================================================================= * Author Date Description * ------------ ---------- --------------------------------------------------- * xshu 2014-05-28 ?????????????? * ============================================================================= */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.Deflater; public class Main { public static byte[] deflater(final byte[] inputByte) throws IOException { int compressedDataLength = 0; Deflater compresser = new Deflater(); compresser.setInput(inputByte); compresser.finish(); ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length); byte[] result = new byte[1024]; try { while (!compresser.finished()) { compressedDataLength = compresser.deflate(result); o.write(result, 0, compressedDataLength); } } finally { o.close(); } compresser.end(); return o.toByteArray(); } }