Example usage for org.apache.commons.compress.archivers.jar JarArchiveEntry getMethod

List of usage examples for org.apache.commons.compress.archivers.jar JarArchiveEntry getMethod

Introduction

In this page you can find the example usage for org.apache.commons.compress.archivers.jar JarArchiveEntry getMethod.

Prototype

public int getMethod() 

Source Link

Document

Returns the compression method of this entry, or -1 if the compression method has not been specified.

Usage

From source file:org.apache.openejb.maven.plugin.customizer.monkey.jar.JarPatcher.java

private int unjar(final File exploded, final File from) {
    int method = -1;

    JarArchiveInputStream stream = null;
    try {//from  w  ww  .  ja v  a  2  s . co m
        stream = new JarArchiveInputStream(new FileInputStream(from));
        JarArchiveEntry entry;
        while ((entry = stream.getNextJarEntry()) != null) {
            final File archiveEntry = new File(exploded, entry.getName());
            archiveEntry.getParentFile().mkdirs();
            if (entry.isDirectory()) {
                archiveEntry.mkdir();
                continue;
            }

            final OutputStream out = new FileOutputStream(archiveEntry);
            IOUtils.copy(stream, out);
            out.close();
            if (method < 0) {
                method = entry.getMethod();
            }
        }
    } catch (final IOException e) {
        throw new IllegalArgumentException(e);
    } finally {
        IO.close(stream);
    }

    return method;
}

From source file:org.springframework.boot.loader.tools.JarWriter.java

private void setUpEntry(JarFile jarFile, JarArchiveEntry entry) throws IOException {
    try (ZipHeaderPeekInputStream inputStream = new ZipHeaderPeekInputStream(jarFile.getInputStream(entry))) {
        if (inputStream.hasZipHeader() && entry.getMethod() != ZipEntry.STORED) {
            new CrcAndSize(inputStream).setupStoredEntry(entry);
        } else {//from  www. ja va 2s. c  o  m
            entry.setCompressedSize(-1);
        }
    }
}