• 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

read Zipfile within a zipfile

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am trying to calculate the checksum of files within a zip file. If any of those files happens to be another zip file then i have to calculate the checksum of the files within the new zipfile. when I try to do that it throws

I understand it is looking for the zipfile in the physical location.
Is there any work around it? I don't want to extract the zipfile into a temp directory..
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's your code look like?
 
Nijeesh Balan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the code :

[ April 17, 2003: Message edited by: Nijeesh BH ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ZipFile class expects a physical file to look at, period. There are two basic workarounds:
  • Copy bytes from the entry's InputStream into a new temp file somewhere, then create a new ZipFile to read the file.
  • Use ZipInputStream rather than ZipFile. ZipInputStream can read from any input stream, so you can use it on a physical file, or on another ZipInputStream. It's a bit more complicated to use than ZipFile, but not much.
  • The tempfile approach will be slower, but if anything goes wrong it's probably easier to debug - you get a nice file as an intermediate step, which you can look at with some other tool like WinZip to see if it's what you're expecting. Even if you use the ZipInputStream approach, it may be useful for debugging to copy the contents for each ZipEntry to an intermediate file.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic