Package java.util.zip

Examples of java.util.zip.GZIPOutputStream.finish()


        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try
        {
            GZIPOutputStream gzip = new GZIPOutputStream(baos);
            gzip.write(bytes, 0, bytes.length);
            gzip.finish();
            byte[] fewerBytes = baos.toByteArray();
            gzip.close();
            baos.close();
            gzip = null;
            baos = null;
View Full Code Here


        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 {
                ObjectHelper.close(gzip, "gzip", null);
                ObjectHelper.close(os, "byte array output stream", null);
            }
View Full Code Here

            GZIPOutputStream gzip = null;
            try {
                os = new ByteArrayOutputStream();
                gzip = new GZIPOutputStream(os);
                gzip.write(data);
                gzip.finish();
                return new ByteArrayInputStream(os.toByteArray());
            } finally {
                ObjectHelper.close(gzip, "gzip", null);
                ObjectHelper.close(os, "byte array", null);
            }
View Full Code Here

    public static byte[] compressGZIP(byte[] data) throws IOException {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(os);
        try {
            gzip.write(data);
            gzip.finish();
            return os.toByteArray();
        } finally {
            gzip.close();
            os.close();
        }
View Full Code Here

        {
            baos = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE);
            gzos = new GZIPOutputStream(baos);

            gzos.write(bytes, 0, bytes.length);
            gzos.finish();
            gzos.close();

            byte[] compressedByteArray = baos.toByteArray();
            baos.close();
View Full Code Here

            oos.writeObject(serializableObject);

            if (gzos != null)
            {
                gzos.finish();
                gzos.close();
            }

            oos.close();
        } // end try
View Full Code Here

                baos = new ByteArrayOutputStream(4096);
                b64os = new Base64.OutputStream(baos, ENCODE | dontBreakLines);
                gzos = new GZIPOutputStream(b64os);

                gzos.write(source, off, len);
                gzos.finish();
                gzos.close();
            } // end try
            catch (IOException e)
            {
                throw e;
View Full Code Here

            try {
                baos = new ByteArrayOutputStream();
                gzos = new GZIPOutputStream(baos);

                gzos.write(writer.toString().getBytes());
                gzos.finish();
                gzos.flush();
                gzos.close();

                return baos.toByteArray();
            }
View Full Code Here

            ByteArrayOutputStream compressedContent = new ByteArrayOutputStream();
            GZIPOutputStream gzipstream = new GZIPOutputStream(
                    compressedContent);
            byte[] bytes = baos.toByteArray();
            gzipstream.write(bytes);
            gzipstream.finish();
            // get the compressed content
            byte[] compressedBytes = compressedContent.toByteArray();
            // set appropriate HTTP headers
            response.setContentLength(compressedBytes.length);
            response.addHeader("Content-Encoding", "gzip");
View Full Code Here

        // response
        else if (bufferedOutput instanceof GZIPOutputStream) {
            // cast to appropriate type
            GZIPOutputStream gzipstream = (GZIPOutputStream) bufferedOutput;
            // finish the compression
            gzipstream.finish();
            // finish the response
            output.flush();
            output.close();
            closed = true;
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.