Breaking News
Home / Java / Java Tutorials / How to extract a zipped file using Java?

How to extract a zipped file using Java?

Unzip File using Java

Building a Zip utility like Winzip is easy in Java, similarly building a unzip tool is easy too,  thanks to java.util.zip package.

Basically in this case we need to open a ZipInputStream to reference the zipped file that we want to extract. Then loop through all the ZipEntry defined in the file. Each ZipEntry represent a file that is packaged into the zip file. While looping, create a handle for each of the output file using FileOutputStream. Then read the byte chucks of that file from the ZipInputStream and write it to FileOutputStream and flush. Once done extracting all the files, finally close the zip output stream. As a result of this, the output folder will contain all the extracted files what were contained in the zip.


 [pb_builder]

Check Also

Have a Question

How to select a JVM Analyzing Tool?

A JVM monitoring tool also know as a Diagnostic might be needed to fine tune …

Advertisment ad adsense adlogger