Read Jar inside Jar?

This is the only area I could think of to put this question…

This is a simple question… If I am reading from a Jar file and I find a Jar inside that I also want to read from… How do I read from the Jar inside the Jar? Is it possible?

You used a JarInputStream to read from the JAR. The JarInputStream gives you an InputStream for each file in the JAR. You can then feed this InputStream to a new instance of JarInputStream and recursively read files :slight_smile:

That is what I thought but actually (according to the javadoc) the JarInputStream itself is the InputStream for the entries… So do I just create a new JarInputStream using the JarInputStream when I get to a Jar inside the Jar?

Yup!


JarEntry entry = jarInputStream.getNextJarEntry();

JarInputStream jarEntryStream = new JarInputStream(jarInputStream);
JarEntry innerEntry = jarEntryStream.getNextJarEntry();

Ok… Thx for the help! :smiley: