Code example for GZIPOutputStream

Methods: finish

0
    } 
 
    public static InputStream compressGzip(String contentEncoding, InputStream in) throws IOException {
        if (isGzip(contentEncoding)) {
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            GZIPOutputStream gzip = new GZIPOutputStream(os);
            try { 
                IOHelper.copy(in, gzip);
                gzip.finish();
                return new ByteArrayInputStream(os.toByteArray());
            } finally { 
                IOHelper.close(gzip, "gzip");
                IOHelper.close(os, "byte array output stream");
            } 
        } else { 
            return in;
        } 
    } 
 
    public static InputStream compressGzip(String contentEncoding, byte[] data) throws IOException {