开发者

Count files in ZIP's directory - JAVA, Android

开发者 https://www.devze.com 2023-01-31 19:09 出处:网络
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.To count all files use ZipFile.size().

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.


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.


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++;
             }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号