Example usage for org.apache.commons.compress.archivers.zip ZipFile entries

List of usage examples for org.apache.commons.compress.archivers.zip ZipFile entries

Introduction

In this page you can find the example usage for org.apache.commons.compress.archivers.zip ZipFile entries.

Prototype

Map entries

To view the source code for org.apache.commons.compress.archivers.zip ZipFile entries.

Click Source Link

Document

Maps ZipArchiveEntrys to Longs, recording the offsets of the local file headers.

Usage

From source file:com.taobao.android.builder.tools.zip.ZipUtils.java

public static boolean removeZipEntry(File file, Pattern pattern, File targetFile)
        throws FileNotFoundException, IOException {
    byte[] buffer = new byte[1024];
    java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(file);
    ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(targetFile)));
    BufferedOutputStream bo = new BufferedOutputStream(out);
    InputStream inputStream;/*w w w  . java  2 s. c  o  m*/
    Enumeration enumeration = zipFile.entries();
    while (enumeration.hasMoreElements()) {
        ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
        String name = zipEntry.getName();
        if (pattern.matcher(name).find()) {
            continue;
        }
        out.putNextEntry(zipEntry);
        inputStream = zipFile.getInputStream(zipEntry);
        write(inputStream, out, buffer);
        bo.flush();

    }

    closeQuitely(zipFile);
    closeQuitely(out);
    closeQuitely(bo);

    return true;
}