• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to check if a Zip file can be opened, and list all file names inside the ZIP?  RSS feed

 
Yaoyuan Fan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java, is it possible to check if a Zip file can be opened, and list all file names inside the ZIP?
Thanks in advance!
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is what you are looking for.

http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/ZipInputStream.html

the API is pretty straight forward, if you have problems getting along just post.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ZipFile can also be used. Don't forget to close the ZipFile or ZipInputStream when you're done with it, regardless which one you choose.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!