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.
Asked
Active
Viewed 3,528 times
2 Answers
2
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.

OrangeDog
- 36,653
- 12
- 122
- 207
-
I want only count files in specify directory not all zip file. – Kumien Dec 23 '10 at 14:39
0
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++;
}

Roadies
- 3,309
- 2
- 30
- 46