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, can show me an example of the program?? cos i hav found some prog, but there are some errors in the program, so i not very sure on how to use it. Thanx in advance....
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...
You could take that unzip method and have it just look through the test file and see if it throws any exceptions i.e. modify it so that it doesn't write the files at all.
Hi, i try the above codes, but there is no main method. It have 1 error. May I know whether how this program runs?? Thanx in advance.... [ September 03, 2003: Message edited by: Ann Toh ]
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.
Don't get me started about those stupid light bulbs.