Example usage for org.apache.commons.compress.parallel InputStreamSupplier get

List of usage examples for org.apache.commons.compress.parallel InputStreamSupplier get

Introduction

In this page you can find the example usage for org.apache.commons.compress.parallel InputStreamSupplier get.

Prototype

InputStream get();

Source Link

Document

Supply an input stream for a resource.

Usage

From source file:org.codehaus.plexus.archiver.jar.JarArchiver.java

/**
 * Overridden from Zip class to deal with manifests and index lists.
 */// w w w  . j  ava2s.  c  o m
protected void zipFile(InputStreamSupplier is, ConcurrentJarCreator zOut, String vPath, long lastModified,
        File fromArchive, int mode, String symlinkDestination) throws IOException, ArchiverException {
    if (MANIFEST_NAME.equalsIgnoreCase(vPath)) {
        if (!doubleFilePass || skipWriting) {
            filesetManifest(fromArchive, is.get());
        }
    } else if (INDEX_NAME.equalsIgnoreCase(vPath) && index) {
        getLogger().warn("Warning: selected " + archiveType + " files include a META-INF/INDEX.LIST which will"
                + " be replaced by a newly generated one.");
    } else {
        if (index && (!vPath.contains("/"))) {
            rootEntries.addElement(vPath);
        }
        super.zipFile(is, zOut, vPath, lastModified, fromArchive, mode, symlinkDestination);
    }
}

From source file:org.codehaus.plexus.archiver.zip.AbstractZipArchiver.java

private InputStreamSupplier wrappedRecompressor(final ZipArchiveEntry ze, final InputStreamSupplier other) {

    return new InputStreamSupplier() {
        public InputStream get() {
            InputStream is = other.get();
            byte[] header = new byte[4];
            try {
                int read = is.read(header);
                boolean compressThis = doCompress;
                if (!recompressAddedZips && isZipHeader(header)) {
                    compressThis = false;
                }//  ww  w.j av a2  s  .c o m

                ze.setMethod(compressThis ? ZipArchiveEntry.DEFLATED : ZipArchiveEntry.STORED);

                return maybeSequence(header, read, is);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

        }
    };
}

From source file:org.codehaus.plexus.archiver.zip.ConcurrentJarCreator.java

/**
 * Adds an archive entry to this archive.
 * <p/>// w ww .j a v  a2s.co  m
 * This method is expected to be called from a single client thread
 *
 * @param zipArchiveEntry The entry to add. Compression method
 * @param source          The source input stream supplier
 * @throws java.io.IOException
 */

public void addArchiveEntry(final ZipArchiveEntry zipArchiveEntry, final InputStreamSupplier source)
        throws IOException {
    final int method = zipArchiveEntry.getMethod();
    if (method == -1)
        throw new IllegalArgumentException("Method must be set on the supplied zipArchiveEntry");
    if (zipArchiveEntry.isDirectory() && !zipArchiveEntry.isUnixSymlink()) {
        final ByteArrayInputStream payload = new ByteArrayInputStream(new byte[] {});
        directories.addArchiveEntry(
                createZipArchiveEntryRequest(zipArchiveEntry, createInputStreamSupplier(payload)));
        payload.close();
    } else if ("META-INF".equals(zipArchiveEntry.getName())) {
        InputStream payload = source.get();
        if (zipArchiveEntry.isDirectory())
            zipArchiveEntry.setMethod(ZipEntry.STORED);
        metaInfDir.addArchiveEntry(
                createZipArchiveEntryRequest(zipArchiveEntry, createInputStreamSupplier(payload)));
        payload.close();
    } else if ("META-INF/MANIFEST.MF".equals(zipArchiveEntry.getName())) {
        InputStream payload = source.get();
        if (zipArchiveEntry.isDirectory())
            zipArchiveEntry.setMethod(ZipEntry.STORED);
        manifest.addArchiveEntry(
                createZipArchiveEntryRequest(zipArchiveEntry, createInputStreamSupplier(payload)));
        payload.close();
    } else {
        parallelScatterZipCreator.addArchiveEntry(zipArchiveEntry, source);
    }
}