Example usage for java.util.zip ZipOutputStream setLevel

List of usage examples for java.util.zip ZipOutputStream setLevel

Introduction

In this page you can find the example usage for java.util.zip ZipOutputStream setLevel.

Prototype

public void setLevel(int level) 

Source Link

Document

Sets the compression level for subsequent entries which are DEFLATED.

Usage

From source file:pl.umk.mat.zawodyweb.www.zip.ZipFile.java

public static byte[] zipContest(Contests contest) throws IOException, JAXBException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipOutputStream out = new ZipOutputStream(baos);
    out.setMethod(ZipOutputStream.DEFLATED);
    out.setLevel(java.util.zip.Deflater.BEST_COMPRESSION);

    Contest xml = new Contest();
    ZipContest.addContest(out, xml, contest);
    putXml(out, "contest.xml", xml);

    out.close();/*w ww.  j a va 2  s.  c  o m*/

    return baos.toByteArray();
}

From source file:pl.umk.mat.zawodyweb.www.zip.ZipFile.java

public static byte[] zipSerie(Series serie) throws IOException, JAXBException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipOutputStream out = new ZipOutputStream(baos);
    out.setMethod(ZipOutputStream.DEFLATED);
    out.setLevel(java.util.zip.Deflater.BEST_COMPRESSION);

    Serie xml = new Serie();
    ZipSerie.addSerie(out, xml, serie);/*from   w w w  .j  a  v  a  2  s  . c om*/
    putXml(out, "serie.xml", xml);

    out.close();

    return baos.toByteArray();
}

From source file:pl.umk.mat.zawodyweb.www.zip.ZipFile.java

public static byte[] zipProblem(Problems problem) throws IOException, JAXBException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipOutputStream out = new ZipOutputStream(baos);
    out.setMethod(ZipOutputStream.DEFLATED);
    out.setLevel(java.util.zip.Deflater.BEST_COMPRESSION);

    Problem xml = new Problem();
    ZipProblem.addProblem(out, xml, problem);
    putXml(out, "problem.xml", xml);

    out.close();//  w  w  w  .  j  a v a2  s  . c  o m

    return baos.toByteArray();
}

From source file:pl.umk.mat.zawodyweb.www.zip.ZipFile.java

public static byte[] zipTest(Tests test) throws IOException, JAXBException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipOutputStream out = new ZipOutputStream(baos);
    out.setMethod(ZipOutputStream.DEFLATED);
    out.setLevel(java.util.zip.Deflater.BEST_COMPRESSION);

    Test xml = new Test();
    ZipTest.addTest(out, xml, test);//from w  w w . j  a  va2s.c o m
    putXml(out, "test.xml", xml);

    out.close();

    return baos.toByteArray();
}

From source file:pl.umk.mat.zawodyweb.www.zip.ZipFile.java

public static byte[] zipTests(List<Tests> tests) throws IOException, JAXBException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipOutputStream out = new ZipOutputStream(baos);
    out.setMethod(ZipOutputStream.DEFLATED);
    out.setLevel(java.util.zip.Deflater.BEST_COMPRESSION);

    pl.umk.mat.zawodyweb.database.xml.Tests xml = new pl.umk.mat.zawodyweb.database.xml.Tests();
    for (Tests test : tests) {
        Test xmlTest = new Test();
        ZipTest.addTest(out, xmlTest, test);
        xml.getTests().add(xmlTest);/* w  w  w.  j  a  v  a 2 s  .co m*/
    }
    putXml(out, "tests.xml", xml);

    out.close();

    return baos.toByteArray();
}

From source file:org.xdi.util.io.ResponseHelper.java

public static ZipOutputStream createZipStream(OutputStream output, String comment) {
    ZipOutputStream zos = new ZipOutputStream(output);

    zos.setComment("Shibboleth2 SP configuration files");
    zos.setMethod(ZipOutputStream.DEFLATED);
    zos.setLevel(Deflater.DEFAULT_COMPRESSION);

    return zos;//from www.j  a v a 2 s .  c om
}

From source file:org.springframework.integration.zip.transformer.SpringZipUtils.java

private static void pack(Collection<ZipEntrySource> entries, OutputStream outputStream, int compressionLevel) {

    ZipOutputStream out = null;
    final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);

    try {//from  www . j a  va 2  s  .  c om
        out = new ZipOutputStream(bufferedOutputStream);
        out.setLevel(compressionLevel);
        for (ZipEntrySource entry : entries) {
            addEntry(entry, out);
        }
    } catch (IOException e) {
        throw rethrow(e);
    } finally {
        IOUtils.closeQuietly(out);
    }

}

From source file:org.fusesource.meshkeeper.util.internal.FileSupport.java

public static void jar(File source, File target) throws IOException {
    ZipOutputStream os = new ZipOutputStream(new FileOutputStream(target));
    try {//from  w  ww.  j  a  v a 2 s  . co m
        os.setMethod(ZipOutputStream.DEFLATED);
        os.setLevel(5);
        recusiveJar(os, source, null);
    } catch (IOException ioe) {
        IOException nioe = new IOException("Error jarring " + source);
        nioe.initCause(ioe);
        throw nioe;
    } finally {
        close(os);
    }
}

From source file:de.blizzy.backup.Utils.java

public static void zipFile(File source, File target) throws IOException {
    ZipOutputStream out = null;
    try {/*from ww  w  .ja  v a2 s .  c om*/
        out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(target)));
        out.setLevel(Deflater.BEST_COMPRESSION);

        ZipEntry entry = new ZipEntry(source.getName());
        entry.setTime(source.lastModified());
        out.putNextEntry(entry);

        Files.copy(source.toPath(), out);
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:org.openflexo.toolbox.ZipUtils.java

public static void makeZip(File zipOutput, File fileToZip, IProgress progress, FileFilter filter, int level)
        throws IOException {
    FileUtils.createNewFile(zipOutput);// w ww .ja  va  2s  .c  o m
    ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipOutput));
    zos.setLevel(level);
    try {
        if (fileToZip.isDirectory()) {
            if (progress != null) {
                progress.resetSecondaryProgress(FileUtils.countFilesInDirectory(fileToZip, true) + 1);
            }
            zipDir(fileToZip.getParentFile().getAbsolutePath().length() + 1, fileToZip, zos, progress, filter);
        } else {
            zipFile(fileToZip, zos, progress);
        }
    } finally {
        zos.close();
    }
}