• Post Reply Bookmark Topic Watch Topic
  • New Topic

read Zipfile within a zipfile  RSS feed

 
Nijeesh Balan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • 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..
 
Tom Purl
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's your code look like?
 
Nijeesh Balan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code :

[ April 17, 2003: Message edited by: Nijeesh BH ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • 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.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!