ZipFile entries() function in Java with examples
The entries() function is a part of java.util.zip package. The function returns the enumeration of zip file entries of the zip file.
public Enumeration entries()
Parameters: The function does not require any parameters
Return value: The function returns the enumeration of zip file entries of the zip file, the enumeration contains the ZipEntry of all the files in the zip file.
Exceptions: The function throws IllegalStateException if the zip file has been closed.
Below programs illustrates the use of entries() function
Example 1: Create a file named zip_file and get the zip file entries using entries() function. “file.zip” is a zip file present in f: directory.
Entries: file3.cpp file1.cpp file2.cpp
Example 2: Create a file named zip_file and get the zip file entries using entries() function. This function throws exception if we close the file and then call the function entries().
zip file closed
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.