Skip to content Skip to sidebar Skip to footer

Count Files In Zip's Directory - Java, Android

I have a little irritating problem. How can I count files in directory in Zip? I want to avoid use ZipFile.entries() and then test every enum.

Solution 1:

To count all files use ZipFile.size().

To count files in a specific directory the method you describe is the only option. Zip files are stored not with a hierarchical structure, just as a flat list with the file paths given.

It also varies as to whether these paths are absolute (for the source file system) or relative.

Solution 2:

For count file on particular directory use below code.

intSdcardcount=0;
 FilefileCount=newFile(dirPath);
             File[] list = fileCount.listFiles();
             for (File f : list) {
             Stringname= f.getName();
             if (name.endsWith(".zip"))
             Sdcardcount++;
             }

Post a Comment for "Count Files In Zip's Directory - Java, Android"