Deflater deflater = new Deflater(Deflater.BEST_SPEED);
deflater.setInput(inBytes);
ByteArrayOutputStream bos = new ByteArrayOutputStream(inBytes.length);
deflater.finish();
byte[] buffer = new byte[1024 * 8];
while (!deflater.finished()) {
int count = deflater.deflate(buffer);
bos.write(buffer, 0, count);
}
byte[] output = bos.toByteArray();
return output;