Tuesday, February 09, 2010

Retrieving the contents of a ZIP file

This Java tip illustrates a method of listing the contents of a ZIP file. Developer may use this as a functionality for its users to first see the contents of the ZIP file and then decompress the chosen one.
try {
ZipFile sourcefile = new ZipFile("source.zip");
for (Enumeration entries = sourcefile.entries(); entries.hasMoreElements();) {
String zipEntryName = ((ZipEntry)entries.nextElement()).getName();
}
} catch (IOException e) {
}

Source: java-tips.org

No comments:

Computers Add to Technorati Favorites Programming Blogs - BlogCatalog Blog Directory