file - Alternative JAVA WAR/ZIP/JAR reader/manipulator library -
i struggling find alternative library make browsing some.war file.
problem need parse war file find specific jar name , of contents inside jar file. must parse contents e.g. pom.xml jars create separate maven project module dependencies , configuration appended other resources. found java.util.zip package bit inconvenient , cluttering.
is there alternative java.util.zip make parsing/reading war without such headaches switching between zipfile/zipentry -> jarfile/jarentry ? treat zip/war/jar , jar files inside war archive directory ? or 1 must craft his/her own solution ?
thank you,
i used zipinputstream
similar task: if wrap 1 zipinputstream
one, can transparently access archive inside archive without unpacking top-level one. here's short sample showing how use it:
public class ziptest { public static void main(string[] args) throws ioexception { try(inputstream = new fileinputstream(args[0])) { listzipentries(1, is); } } private static void listzipentries(int indent, inputstream is) throws ioexception { zipinputstream zip = new zipinputstream(is); while(true) { zipentry entry = zip.getnextentry(); if(entry == null) return; system.out.printf("%"+indent+"s%s\n", "", entry.getname()); if(entry.getname().endswith(".zip") || entry.getname().endswith(".jar")) listzipentries(indent+3, zip); } } }
it dumps names of files inside zip-archive. if encounters file name ends .zip
or .jar
, goes inside , dumps recursively. me looks quite simple , no third-party code necessary.
Comments
Post a Comment