Update: Sorry, it's probably too late for your needs, I just noticed your last question in the comments. Therefore, I modified the example to show that each nested record is copied directly to the OutputStream without the need to inflate an external can.
In this case, OutputStream is System.out , but can be any OutputStream (for example, a file ...).
No need to use a temporary file. You can use a JarInputStream instead of a JarFile , pass an InputStream from an external record to the constructor, and then you can read the contents of the flag.
For instance:
JarFile jarFile = new JarFile(warFile); Enumeration entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry jarEntry = (JarEntry) entries.nextElement(); if (jarEntry.getName().endsWith(".jar")) { JarInputStream jarIS = new JarInputStream(jarFile .getInputStream(jarEntry));
source share