Reputation: 3157
Java 7 introduced a zip FileSystem. The link below illustrates how to create a zip FileSystem from a zip file.
http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html
However, I can find no example of how to create a zip FileSystem from an InputStream. Is that possible? If so, how?
Note: I know I can write the InputStream to disk and create a zip FileSystem as described. I consider that a hack, and I would prefer to avoid it.
Upvotes: 4
Views: 2846
Reputation: 101
Only a partial answer, but I expect you'll need a custom file system provider and this question about an in-memory file system might help. Note that the newFileSystem documentation shows a memory://...
URL scheme, but no more detail.
As pointed out in another answer, the file system requires bidirectional access to the data, so this assumes enough memory to load it entirely.
Upvotes: 2
Reputation: 3155
No, it's not possible because the file system requires random access to the ZIP file.
Shameless self-plug: You may find TrueZIP easier to work with and more powerful. However, the same constraint applies to it, too.
Upvotes: 4