public class JarDir { public static void main (String args[]) throws IOException { if (args.length != 1) { System.out.println( "Please provide a JAR filename"); System.exit(-1); } JarFile jarFile = new JarFile(args[0]); Enumeration enum = jarFile.entries(); while (enum.hasMoreElements()) { process(enum.nextElement()); } }
private static void process(Object obj) { JarEntry entry = (JarEntry)obj; String name = entry.getName(); long size = entry.getSize(); long compressedSize = entry.getCompressedSize(); System.out.println( name + "/t" + size + "/t" + compressedSize); } }
public class JarRead { public static void main (String args[]) throws IOException { if (args.length != 2) { System.out.println( "Please provide a JAR filename and file to read"); System.exit(-1); } JarFile jarFile = new JarFile(args[0]); JarEntry entry = jarFile.getJarEntry(args[1]); InputStream input = jarFile.getInputStream(entry); process(input); jarFile.close(); }