1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
/* Get All Entries From Zip File Example. This Java example shows how to get enumeration of all entries (i.e. files or directories) using entries method of Java ZipFile class. */ import java.io.IOException; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class GetAllEntries { public static void main(String args[]) { try { /* * Open zip file using, * * ZipFile(String fileName) * constructor of the ZipFile class. * * This constructor throws IOException for any I/O error. */ ZipFile zipFile = new ZipFile("c:/FileIO/WebFiles.zip"); /* * To get all entries from opened zip file, use * * Enumeration entries() * method of ZipFile class. * * This method returns Enumeration of zip file entries. */ Enumeration e = zipFile.entries(); /* * PLEASE VISIT ZipEntry Examples for more details on * how to process entries. */ /* * close the opened zip file using, * void close() * method. */ zipFile.close(); } catch(IOException ioe) { System.out.println("Error opening zip file" + ioe); } } } |
Add Comment