ZipFile size() function in Java with examples
The size() function is a part of java.util.zip package. The function returns the number of entries of the zip file.
public int size()
Parameters: The function does not require any parameters
Return value: The function returns a Integer, which is the number of entries of the zip file
Exceptions: The function throws IllegalStateException if the zip file has been closed
Below programs illustrates the use of size() function
Example 1: Create a file named zip_file and get the number of entries using size() function.”file.zip” is a zip file present in f: directory.
number of entries= 7
Example 2: Create a file named zip_file and get the number of entries using size() function. we will try to see whether the function throws an exception if we close the file and then call the function size().
zip file closed