开发者

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.


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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜