Android examples for File Input Output:Byte Array Compress
compress byte array
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPOutputStream; public class Main { public static byte[] compress(byte[] src) throws IOException { GZIPOutputStream gzip = null; ByteArrayOutputStream baos = null; try {/*from w ww . j a v a 2 s . c o m*/ baos = new ByteArrayOutputStream(); gzip = new GZIPOutputStream(baos); gzip.write(src); gzip.finish(); return baos.toByteArray(); } finally { if (gzip != null) { gzip.close(); } if (baos != null) { baos.close(); } } } }