Get Number Of Entries In Zip File - Java File Path IO

Java examples for File Path IO:Zip File

Description

Get Number Of Entries In Zip File

Demo Code

import java.io.IOException;
import java.util.zip.ZipFile;
 
public class Main {
 
        public static void main(String args[])
        {//  w ww. j a v a2 s  .com
                 try
                 {
                        ZipFile zipFile = new ZipFile("c:/Folder/WebFiles.zip");
                         int numberOfEntries = zipFile.size();
                         
                         System.out.println("There are ");
                         System.out.print(numberOfEntries);
                         System.out.print(" entries in zip file :");
                         System.out.print(zipFile.getName());  
                         zipFile.close();
       
                 }
                 catch(IOException ioe)
                 {
                        System.out.println("Error opening zip file" + ioe);
                 }
        }
}

Result


Related Tutorials