Java examples for File Path IO:GZIP
Compresses a byte array with gzip
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPOutputStream; public class Main { /**//from ww w .ja v a2 s.com * Compresses a byte array */ public static byte[] compress(byte[] theBytes) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gos = new GZIPOutputStream(bos); gos.write(theBytes); gos.close(); return bos.toByteArray(); } }