Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ZIP File reading

 
Billy Nicholson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found out the answer.
Wrap a ZipInputStream around a ZipInputStream

ZipInputStream firstLevel = new ZipInputStream(ZipFile.getInputStream(ZipEntry));
firstLevel.getNextEntry();
ZipInputStream secondLevel = new ZipInputStream(firstLevel);
etc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic