Example usage for org.apache.poi.openxml4j.util ZipEntrySource getEntries

List of usage examples for org.apache.poi.openxml4j.util ZipEntrySource getEntries

Introduction

In this page you can find the example usage for org.apache.poi.openxml4j.util ZipEntrySource getEntries.

Prototype

Enumeration<? extends ZipArchiveEntry> getEntries();

Source Link

Document

Returns an Enumeration of all the Entries

Usage

From source file:org.apache.tika.parser.microsoft.ooxml.xps.XPSExtractorDecorator.java

License:Apache License

private static InputStream getZipStream(String zipPath, ZipPackage zipPackage)
        throws IOException, TikaException {
    String targPath = (zipPath.length() > 1 && zipPath.startsWith("/") ? zipPath.substring(1) : zipPath);
    ZipEntrySource zipEntrySource = zipPackage.getZipArchive();
    Enumeration<? extends ZipEntry> zipEntryEnumeration = zipEntrySource.getEntries();
    ZipEntry zipEntry = null;/*  ww w.jav a 2 s  . c  o  m*/
    while (zipEntryEnumeration.hasMoreElements()) {
        ZipEntry ze = zipEntryEnumeration.nextElement();
        if (ze.getName().equals(targPath)) {
            zipEntry = ze;
            break;
        }
    }
    if (zipEntry == null) {
        throw new TikaException("Couldn't find required zip entry: " + zipPath);
    }
    return zipEntrySource.getInputStream(zipEntry);
}