File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes ZIP File reading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "ZIP File reading" Watch "ZIP File reading" New topic

ZIP File reading

Billy Nicholson

Joined: Jun 16, 2011
Posts: 8
Let's say you have a Zip File and you want to read it. You just take the ZipFile and .getInputStream(ZipEntry). Well, let's say the entry you want to read is a zip file, itself. Well, you: ZipInputStream inputStream = new ZipInputStream((zipFileHere).getInputStream(ZipEntry)). And then you read from there. Now, let's say you have a triple nested zip file. That is to say, a zip file...inside a zip file... inside a zip fie. How would you read from that? ZipInputStream doesn't have a ".getInputStream(ZipEntry e)" method...
Billy Nicholson

Joined: Jun 16, 2011
Posts: 8
Found out the answer.
Wrap a ZipInputStream around a ZipInputStream

ZipInputStream firstLevel = new ZipInputStream(ZipFile.getInputStream(ZipEntry));
ZipInputStream secondLevel = new ZipInputStream(firstLevel);
I agree. Here's the link:
subject: ZIP File reading
It's not a secret anymore!