• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to unzip a zip file which contains another zip file?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to unzip a zip file which contains 2 text files and another zip file inside it.

For example, the zip file to unzip is called "Books.zip" and it contains 2 text files and another zip file called "Price.zip".

I googled for the unzipping code commonly found on the net and used it. But the problem is that the code can only unzip the 2 text files. It seems unable to retrieve the contents inside the "Price.zip" folder.

The code used is shown below:


How do I unzip and retrieve all the contents of a zip file which contains another zip file?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For unzipping it doesn't matter what type the files are; they're just treated as bytes anyway. The process doesn't work recursively, though. After you've unzipped Books.zip, you'll need to re-run this code with Price.zip.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That should allow you to unzip the second file without extracting it. I'm a bit lazy regarding the copying here, but basically reading from a ZipInputStream reads everything for the current entry. You need to close that entry and go the next entry and copy everything again, until your done.
 
reply
    Bookmark Topic Watch Topic
  • New Topic