Examples of CBZip2OutputStream


Examples of org.apache.tools.bzip2.CBZip2OutputStream

                return new GZIPOutputStream(ostream);
            } else {
                if (BZIP2.equals(value)) {
                    ostream.write('B');
                    ostream.write('Z');
                    return new CBZip2OutputStream(ostream);
                }
            }
            return ostream;
        }
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2OutputStream

* @ant.task category="packaging"
*/

public class BZip2 extends Pack {
    protected void pack() {
        CBZip2OutputStream zOut = null;
        try {
            BufferedOutputStream bos =
                new BufferedOutputStream(new FileOutputStream(zipFile));
            bos.write('B');
            bos.write('Z');
            zOut = new CBZip2OutputStream(bos);
            zipFile(source, zOut);
        } catch (IOException ioe) {
            String msg = "Problem creating bzip2 " + ioe.getMessage();
            throw new BuildException(msg, ioe, getLocation());
        } finally {
            if (zOut != null) {
                try {
                    // close up
                    zOut.close();
                } catch (IOException e) {
                    //ignore
                }
            }
        }
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2OutputStream

                return new GZIPOutputStream(ostream);
            } else {
                if (BZIP2.equals(value)) {
                    ostream.write('B');
                    ostream.write('Z');
                    return new CBZip2OutputStream(ostream);
                }
            }
            return ostream;
        }
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2OutputStream

    }
   
    private void compress() throws IOException {
        InputStream in = null;
        OutputStream out = null;
        CBZip2OutputStream bzout = null;
       
        if (use_stdout) {
            bzout = new CBZip2OutputStream(stdout, clevel);
        }
       
        for (File file : files) {
            if (file.getName().equals("-")) {
                processStream(stdin, bzout);
                continue;
            }
           
            try {
                if (use_stdout) {
                    if ((in = openFileRead(file)) == null) {
                        rc = 1;
                        continue;
                    }
                    processStream(in, bzout);
                    continue;
                }
                try {
                    File bzfile = new File(file.getAbsolutePath() + ".bz2");
                    if ((out = openFileWrite(bzfile, true, force)) == null) {
                        rc = 1;
                        continue;
                    }
                    bzout = new CBZip2OutputStream(out, clevel);
                    if ((in = openFileRead(file)) == null) {
                        rc = 1;
                        continue;
                    }
                    processStream(in, bzout);
                    float sizeDiff = ((float) bzfile.length() / (float) file.length()) * 100;
                    notice(String.format(fmt_size_diff, file, sizeDiff, bzfile));
                    if (!keep) file.delete();
                } finally {
                    close(bzout);
                }
            } finally {
                close(in);
            }
        }
        // TEST need to see if this is even necessary, and if it is
        // should it be within a finally block
        if (use_stdout) {
            bzout.close();
        }
    }
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2OutputStream

    /**
     * Wraps an OutputStream with a compression stream for writing compressed archives.
     */
    private OutputStream wrapOutputStream(OutputStream out) throws IOException {
        if (compress == USE_BZIP) {
            return new CBZip2OutputStream(out);
        }
        if (compress == USE_GZIP) {
            return new GZIPOutputStream(out);
        }
       
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2OutputStream

     */
    protected OutputStream wrapStream(OutputStream out) throws IOException {
        for (int i = 0; i < MAGIC.length; i++) {
            out.write(MAGIC[i]);
        }
        return new CBZip2OutputStream(out);
    }
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2OutputStream

                return new GZIPOutputStream(ostream);
            } else {
                if (BZIP2.equals(v)) {
                    ostream.write('B');
                    ostream.write('Z');
                    return new CBZip2OutputStream(ostream);
                }
            }
            return ostream;
        }
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2OutputStream

    public double d2(String x, String y) {
        String str = x + y;
        double result = 0.0f;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream(str.length());
            CBZip2OutputStream os = new CBZip2OutputStream(baos);
            os.write(str.getBytes());
            os.close();
            baos.close();
            result = baos.toByteArray().length;
        } catch (IOException e) {
            e.printStackTrace();
        }
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2OutputStream

                return new GZIPOutputStream(ostream);
            } else {
                if (BZIP2.equals(v)) {
                    ostream.write('B');
                    ostream.write('Z');
                    return new CBZip2OutputStream(ostream);
                }
            }
            return ostream;
        }
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2OutputStream

* @ant.task category="packaging"
*/

public class BZip2 extends Pack {
    protected void pack() {
        CBZip2OutputStream zOut = null;
        try {
            BufferedOutputStream bos =
                new BufferedOutputStream(new FileOutputStream(zipFile));
            bos.write('B');
            bos.write('Z');
            zOut = new CBZip2OutputStream(bos);
            zipFile(source, zOut);
        } catch (IOException ioe) {
            String msg = "Problem creating bzip2 " + ioe.getMessage();
            throw new BuildException(msg, ioe, getLocation());
        } finally {
            if (zOut != null) {
                try {
                    // close up
                    zOut.close();
                } catch (IOException e) {
                    //ignore
                }
            }
        }
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.