Examples of GZIPOutputStream


Examples of java.util.zip.GZIPOutputStream

     * @return the compressed byte array
     * @throws IOException if an excption occurs
     */
  static byte[] compress(byte[] data) throws IOException {
      ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length);
      GZIPOutputStream out = new GZIPOutputStream(bos);
     
        out.write(data);
        out.close();
        return bos.toByteArray();
    }
View Full Code Here

Examples of java.util.zip.GZIPOutputStream

     * @return the compressed byte array
     * @throws IOException if an excption occurs
     */
    public static byte[] compress(byte[] data) throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length);
        GZIPOutputStream out = new GZIPOutputStream(bos);
       
        out.write(data);
        out.close();
        return bos.toByteArray();
    }
View Full Code Here

Examples of java.util.zip.GZIPOutputStream

     * @return the compressed byte array
     * @throws IOException if an excption occurs
     */
  public static byte[] compress(byte[] data) throws IOException {
      ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length);
      GZIPOutputStream out = new GZIPOutputStream(bos);
     
        out.write(data);
        out.close();
        return bos.toByteArray();
    }
View Full Code Here

Examples of java.util.zip.GZIPOutputStream

                    // check if this file is already compressed, if not, compress now
                    if (!outfile.getName().endsWith(".gz")) {
                        final String gzname = outfile.getName() + ".gz";
                        final File gzfile = new File(outfile.getParentFile(), gzname);
                        try {
                            final OutputStream os = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(gzfile)));
                            FileUtils.copy(new BufferedInputStream(new FileInputStream(outfile)), os);
                            os.close();
                            if (gzfile.exists()) {
                                FileUtils.deletedelete(outfile);
                            }
View Full Code Here

Examples of java.util.zip.GZIPOutputStream

        try {
            os = new BufferedOutputStream(new FileOutputStream(tmp), 4 * 1024 * 1024);
        } catch (final OutOfMemoryError e) {
            os = new FileOutputStream(tmp);
        }
        if (file.getName().endsWith(".gz")) os = new GZIPOutputStream(os);
        int c = 0;
        while (i.hasNext()) {
            os.write(i.next().bytes());
            c++;
        }
View Full Code Here

Examples of java.util.zip.GZIPOutputStream

        // compress a byte array and add a leading magic for the compression
        try {
            //System.out.print("/(" + cdr + ")"); // DEBUG
            final ByteArrayOutputStream baos = new ByteArrayOutputStream(b.length / 5);
            baos.write(gzipMagic);
            final OutputStream os = new GZIPOutputStream(baos, 512);
            os.write(b);
            os.close();
            baos.close();
            return baos.toByteArray();
        } catch (final IOException e) {
            Log.logSevere("Compressor", "", e);
            return null;
View Full Code Here

Examples of java.util.zip.GZIPOutputStream

        return buffer;
    }

    public static byte[] readAndZip(final File source) throws IOException {
        ByteArrayOutputStream byteOut = null;
        GZIPOutputStream zipOut = null;
        try {
            byteOut = new ByteArrayOutputStream((int)(source.length()/2));
            zipOut = new GZIPOutputStream(byteOut);
            copy(source, zipOut);
            zipOut.close();
            return byteOut.toByteArray();
        } finally {
            if (zipOut != null) try { zipOut.close(); } catch (final Exception e) {}
            if (byteOut != null) try { byteOut.close(); } catch (final Exception e) {}
        }
    }
View Full Code Here

Examples of java.util.zip.GZIPOutputStream

            if (fos != null) try {fos.close();} catch (final Exception e) {}
        }
    }

    public static void writeAndGZip(final byte[] source, final OutputStream dest) throws IOException {
        GZIPOutputStream zipOut = null;
        try {
            zipOut = new GZIPOutputStream(dest);
            copy(source, zipOut);
            zipOut.close();
        } finally {
            if (zipOut != null) try { zipOut.close(); } catch (final Exception e) {}
        }
    }
View Full Code Here

Examples of java.util.zip.GZIPOutputStream

        final File tf = new File(file.toString() + ".prt" + (System.currentTimeMillis() % 1000));
        OutputStream os = null;
        if ((format == null) || (format.equals("plain"))) {
            os = new BufferedOutputStream(new FileOutputStream(tf));
        } else if (format.equals("gzip")) {
            os = new GZIPOutputStream(new FileOutputStream(tf));
        } else if (format.equals("zip")) {
            final ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(file));
            String name = file.getName();
            if (name.endsWith(".zip")) name = name.substring(0, name.length() - 4);
            zos.putNextEntry(new ZipEntry(name + ".txt"));
View Full Code Here

Examples of java.util.zip.GZIPOutputStream

        final File tf = new File(file.toString() + ".prt" + (System.currentTimeMillis() % 1000));
        OutputStream os = null;
        if ((format == null) || (format.equals("plain"))) {
            os = new BufferedOutputStream(new FileOutputStream(tf));
        } else if (format.equals("gzip")) {
            os = new GZIPOutputStream(new FileOutputStream(tf));
        } else if (format.equals("zip")) {
            final ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(file));
            String name = file.getName();
            if (name.endsWith(".zip")) name = name.substring(0, name.length() - 4);
            zos.putNextEntry(new ZipEntry(name + ".txt"));
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.