My current task is to iterate a .jar to see if it has .jars inside. Then I have to get those .jars and check certain file in each one.To do that, I am using JarFile to get the JarEntries. The problem is, How do I do to get again the JarFile from the current Jar Entry?. Is it possible?
Jar: Jar1: /META-INF/source/file1.txt Jar2: /META-INF/source/file1.txt
Here is my current code:
public static void main(String[] args) throws IOException, URISyntaxException {
String dir = Paths.get(".").toAbsolutePath().normalize().toString() + "/target";
Collection<String> jarBuildList = JarFinder.getJars(dir);
for(String buildJar : jarBuildList){
File file = new File(buildJar);
JarFile buildJarFile = new JarFile(file);
Enumeration<JarEntry> entries = buildJarFile.entries();
while (entries.hasMoreElements()) {
JarEntry jarEntry = entries.nextElement();
if (jarEntry.getName().contains(".jar")){
//Having the JarEntry, enter to that jar javaEntry and get a file1.txt
}
}
}
}
}