Count files in ZIP's directory - JAVA, Android

2019-08-02 14:43发布

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.

2条回答
We Are One
2楼-- · 2019-08-02 15:16

For count file on particular directory use below code.

int Sdcardcount = 0;
 File fileCount = new File(dirPath);
             File[] list = fileCount.listFiles();
             for (File f : list) {
             String name = f.getName();
             if (name.endsWith(".zip"))
             Sdcardcount++;
             }
查看更多
Evening l夕情丶
3楼-- · 2019-08-02 15:20

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.

查看更多
登录 后发表回答