Reading files from ZIP in memory
803451Oct 6 2010 — edited Oct 6 2010Hi,
I need to extract some files from a ZIP archive which will be in memory, accessed with an InputStream (ByteArray).
As ZIP files are likely to be large, I'd like to have some sort of "random access" in the way java.util.ZipFile does, allowing me to access any file directly without having to iterate through all the entries. Unfortunately, ZipFiles can only be constructed from physical Files, but mines will always be in memory, and I can't dump them to disk.
So I think ZipInputStream is the only way to go here, but it imposes me a sequential access to the entries. Maybe I could fully read the file for the first time and save zip entries' offsets in a hash table, but I find it difficult to later seek the ZipInputStream to extract the entries with its offsets and it seems going back (or resetting) is not possible in this kind of streams.
Any idea? Thanks in advance.