public List<File> getFilesInJar(String jarName){
List<File> result = new ArrayList<File>();
File jarFile = new File(jarName);
JarInputStream jarFile = new JarInputStream(new FileInputStream(jarFile));
JarEntry jarEntry;
while ((jarEntry = jarFile.getNextJarEntry()) != null) {
result.add(inputStreamToFile(jarFile.getInputStream(jarEntry)));
}
return result;
}
for the inputStreamToFile method, google "java inputStream to file", although you might be happy with an InputStream object also, instead of a File object :)
For the actual file data, see ZipFile#getInputStream(ZipEntry). The javadocs for that class explain how it is to be used.
The
jar:
protocol is a way to build a URI to a resource in a JAR archive:See the API docs for JarURLConnection: http://java.sun.com/javase/6/docs/api/java/net/JarURLConnection.html
Between the
jar:
and!/
can be any URL, including afile:
URL.for the inputStreamToFile method, google "java inputStream to file", although you might be happy with an InputStream object also, instead of a File object :)