Hi, can anybody tell me how to unzip a file using java codes?? i need to write a java program to unzip a file and read the file inside the zip file. if can, can give me a sample codes to look through. Thanx alot!!
Hi, Use java.util.zip.ZipInputStream for unzipping the zip file, and use ZipInputStream.getNextEntry() to get the ZipEntry object representing each file in the zip file. From the ZipEntry object you can get the name of the file inside the .zip file. -Shashi
Hi, thanx, i will try and see the program. By the way, does anybody noe how to check whether the file is a zip file?? cos i need to let the user upload their files and i need to check whether the files is a zip file or not. If can, can show an example.... Thanx in advance...
Ann: It is merely a utility class, you don't run it directly, you call it from your own program. Shelly: When making a zip file, you calculate a CRC checksum for each file and save it with the zip entry. That way when you unzip a file, you do another CRC checksum and compare it against the checksum for the zip entry, if they do not match then the file is corrupted. The unzip methods originally returned true/false depending on all checksum checks, but I changed it to return a File with all the valid unzipped files. I still have some thinking to do as far as error handling, etc.