• Post Reply Bookmark Topic Watch Topic
  • New Topic

Puzzled in java zip API  RSS feed

 
Haiqiang Shen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method setComment(String) in java.util.zip.ZipOutputStream can put comment to the zip file that I made, but how can I get back the comment from the zip file? There is no such a method getComment() in the class java.util.zip.ZipInputStream or any other zip classes.

Thank you for your help!
 
Eric Daly
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Taking a quick look at the api, I found that the getComment() method you are looking for is in package java.util.zip.ZipEntry
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, ZipEntry has setComments and getComments methods, but those are for a particular entry, not for the file as a whole (which is what Haiqiang is asking about).

Looking at the source, it seems that the comments written by ZipOutputStream.setComments do not seem to get read by ZipInputStream - they're part of a file footer, so to speak, that follows the last entry, and which is disregarded upon reading.
 
Eric Daly
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So then what's the point of setComment()?
 
Siddhartha Ghosh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that the comment set by setComment() can be read by some advanced Archiving Softwares like Winzip, but really I don't know how it might be possible to read the comment using the java.util.zip package.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!