This sample code read the name of all files from a zip file. It uses ZipInputStream to read zip file.
import java.io.*;
import java.util.zip.*;
public class ZipFileRdrExp {
public static void main(String[] args) {
try {
FileInputStream fis = new FileInputStream("C:\\MyZip.zip");
ZipInputStream zis = new ZipInputStream(fis);
ZipEntry ze;
while((ze=zis.getNextEntry())!=null){
System.out.println(ze.getName());
zis.closeEntry();
}
zis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Source: java-tips.org
Saturday, January 02, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment