解压罐子
import java.io.File;/*来 自 nowjava - 时代Java*/ import java.io.FileOutputStream; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; public class Main{ public static List<String> decompressJar(String jarPath, String outPath, String[] filter) throws Exception { JarFile jarFile = new JarFile(jarPath); /** from NowJava.com**/ List<String> webWars = new ArrayList<String>(); Enumeration<JarEntry> entrys = jarFile.entries(); while (entrys.hasMoreElements()) { JarEntry entry = entrys.nextElement(); String name = entry.getName(); if (name.contains("about.html")) continue; for (String string : filter) { if (name.contains(string)) { String file = extractJarEntry(outPath, jarFile, entry); webWars.add(file); } } } jarFile.close(); return webWars; } public static String extractJarEntry(String outPath, JarFile jarFile, JarEntry entry) throws Exception { outPath = outPath.endsWith("/") ? outPath : outPath + '/'; File file = new File(outPath + entry.getName()); if (!file.exists()) {