The getEntry() function is a part of java.util.zip package. The function returns the ZipEntry of file present in the zip file specified by the string parameter.
public ZipEntry getEntry(String name)
Parameters: The function takes a string parameter, the name of the file.
Return value: The function returns the ZipEntry of the zip file specified by the string parameter.
Exceptions: The function throws IllegalStateException if the zip file has been closed.
Below programs illustrates the use of getEntry() function
Example 1: Create a file named zip_file and get the zip file entry using getEntry() function. “file.zip” is a zip file present in f: directory.
Example 2: Create a file named zip_file and get the zip file entry using getEntry() function. “file.zip” is a zip file present in f: directory whereas “file4.cpp” is not present in the zip file.
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.