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++;
}
精彩评论