Package org.apache.poi.openxml4j.util
Class ZipInputStreamZipEntrySource
java.lang.Object
org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ZipEntrySource
Provides a way to get at all the ZipEntries
from a ZipInputStream, as many times as required.
Allows a ZipInputStream to be treated much like
a ZipFile, for a price in terms of memory.
Be sure to call
close()
as soon as you're
done, to free up that memory!-
Constructor Summary
ConstructorsConstructorDescriptionReads all the entries from the ZipInputStream into memory, and don't close (since POI 4.0.1) the source stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Indicates we are done with reading, and resources may be freedEnumeration
<? extends org.apache.commons.compress.archivers.zip.ZipArchiveEntry> Returns an Enumeration of all the Entriesorg.apache.commons.compress.archivers.zip.ZipArchiveEntry
Return an entry by its pathgetInputStream
(org.apache.commons.compress.archivers.zip.ZipArchiveEntry zipEntry) Returns an InputStream of the decompressed data that makes up the entryboolean
isClosed()
Has close been called already?
-
Constructor Details
-
ZipInputStreamZipEntrySource
Reads all the entries from the ZipInputStream into memory, and don't close (since POI 4.0.1) the source stream. We'll then eat lots of memory, but be able to work with the entries at-will.- Throws:
IOException
-
-
Method Details
-
getEntries
public Enumeration<? extends org.apache.commons.compress.archivers.zip.ZipArchiveEntry> getEntries()Description copied from interface:ZipEntrySource
Returns an Enumeration of all the Entries- Specified by:
getEntries
in interfaceZipEntrySource
-
getInputStream
public InputStream getInputStream(org.apache.commons.compress.archivers.zip.ZipArchiveEntry zipEntry) Description copied from interface:ZipEntrySource
Returns an InputStream of the decompressed data that makes up the entry- Specified by:
getInputStream
in interfaceZipEntrySource
-
close
public void close()Description copied from interface:ZipEntrySource
Indicates we are done with reading, and resources may be freed- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceZipEntrySource
-
isClosed
public boolean isClosed()Description copied from interface:ZipEntrySource
Has close been called already?- Specified by:
isClosed
in interfaceZipEntrySource
-
getEntry
Description copied from interface:ZipEntrySource
Return an entry by its path- Specified by:
getEntry
in interfaceZipEntrySource
- Parameters:
path
- the path in unix-notation- Returns:
- the entry or
null
if not found
-