We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Does anyone know of a library or way to use processing to extract the contents of a zip file? If there is a library that does this directly, that would be great, if I have to use in combination with another program that would be ok aswell, but not the preferred option. Hoping someone has an idea of how to achieve this.
Thanks in advance Scott
Answers
Java is able to do that out of the box. Processing handles reading a compressed text file, for example (AFAIK). It uses the GZIPInputStream class for that. That's for .gz files, but for .zip files, there is the ZipInputStream class.
Otherwise, perhaps there is an Apache Commons library to ease exploration of zip files, if you have complex needs.
Thank you very much PhiLho. This was just what I needed. Here is the code that I am now using which I put together from a combination of the following two sites:
A. http://stackoverflow.com/questions/2063099/unzipping-a-file-from-inputstream-and-returning-another-inputstream
and
B. http://concretepage.com/java/read_zip_file_java
Not sure if I need all of those try catch statements, but hey it seems to work fine. And the code: