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

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

Introduction

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

Prototype

InputStream getInputStream(ZipArchiveEntry entry) throws IOException;

Source Link

Document

Returns an InputStream of the decompressed data that makes up the entry

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;/*www  . j a  v a2  s.  c  om*/
    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);
}