Lets learn how to unzip a file using java.
The java.util.zip.ZipEntry class is used to represent a zip file
entry. The java.util.zip.ZipEntry class implements
java.util.zip.ZipConstants interface. Here we passing the zipped file
name to be unzipped using command line argument .To unzip a file first create an
object of byte stream then take the array of any size as per your convenience
(Here we are taking 1000 as the size
of byte array ) then create a text file. First convert the zipped file into the
byte array and then write the zipped file into it, To flush and close the
flush() and close() respectively.
If it throws any exception then catch it in try/catch block. We are printing the whole exception using printStrackTrace() method.
Here is the code of the program :
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: June 19, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles