Here you can find the source of uncompress(final byte[] buffer)
Parameter | Description |
---|---|
buffer | a parameter |
public static byte[] uncompress(final byte[] buffer)
//package com.java2s; //License from project: LGPL import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream; public class Main { /**//w ww .j a va 2 s . c o m * Uncompress a GZIP piece of content * * @param buffer * @return the uncompressed content, or null if there was an error * @since 1.0.2 */ public static byte[] uncompress(final byte[] buffer) { try { final GZIPInputStream gzipis = new GZIPInputStream(new ByteArrayInputStream(buffer)); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final byte[] tmp = new byte[1024]; int len; while ((len = gzipis.read(tmp)) > 0) { baos.write(tmp, 0, len); } baos.flush(); return baos.toByteArray(); } catch (final IOException ioe) { return null; } } }