I'm searching for a way to count the number of files inside an entry of a jar file.
For example, assume I have inside the jar a folder called "myFolder", I want to be able to count the number of files inside of it.
I used the idea from here to get to myFolder, yet I don't know how to get to the files inside.
Here is my code:
private int countFiles() {
JarFile jf = null;
int counter = 0;
try {
jf = new JarFile(new File(ClassName.class
.getProtectionDomain().getCodeSource().getLocation().toURI()));
Enumeration<JarEntry> entries = jf.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (entry.isDirectory()) {
if (entry.getName().equals("myFolder/")) {
///////
}
}
}
} catch (Exception ex) {
try {
jf.close();
} catch (Exception e) {
}
}
return counter;
}
Appreciate the help!