How do I unzip the contents of a zip file?
Author: Deron Eriksson
Description: This Java tutorial describes how to unzip the contents of a zip file.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0)

Page: < 1 2

(Continued from page 1)

The execution of our ExtractZipContents class with the file is shown in the Console view below.

Execution of ExtractZipContents

If we examine our project now, we can see that f1/f2/f3/file5.txt, folder/f3.txt, folder/f4.txt, f1.txt, and f2.txt were created, as expected. I opened the files, and they extracted correctly.

'testing' project following extraction

As you can see, using the package along with some standard JavaSW file and stream code makes it easy to extract the files within a zip file.

Page: < 1 2