// compresser.setInput(ba);
compresser.setInput(bodyBuffer, bodyOffset, bodyLength);
compresser.finish();
ByteArrayOutputStream baos = new ByteArrayOutputStream(output.length);
int numCompressedBytes = 0;
while (!compresser.finished()) {
numCompressedBytes = compresser.deflate(output);
if (numCompressedBytes > 0) {
baos.write(output, 0, numCompressedBytes);
baos.flush();
}