Java tutorial
//package com.java2s; import java.io.*; import java.util.zip.*; public class Main { public static byte[] compressZip(byte bytes[]) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); ZipOutputStream zipos = new ZipOutputStream(os); zipos.putNextEntry(new ZipEntry("ZIP")); zipos.write(bytes, 0, bytes.length); zipos.close(); return os.toByteArray(); } }