以压缩文件或目录的方式过滤.class文件
解决方案 »
- jbpm4.4在部署流程时出错
- 求助JBPM4.4 会签实例
- 关于 java 的异常问题?
- Apache+Tomcat的性能问题
- 求助,关于struts tiles标签
- 问一个Blog里的问题
- ### tomcat中是否可以配置rmi (急,在线等待)### 100分
- 全天在线:救急!!JB8调试EJB客户程序报错,如何纠错??!!!!
- 偶需要weblogic6.0 or 6.01sp4,那位高手请告之!
- 关于java与xml 请freekevin(kevin)继续
- request.getRequestDispatcher重定向错误
- 关于一个validate()表单验证的问题!请大家指点一下吧~!多谢了~
manifest是什么东西,在什么位置的
如果是jar文件,就先解压缩。
public static void listZipClass(File file) throws Exception {
ZipInputStream in = new ZipInputStream(new FileInputStream(file));
try {
ZipEntry ze = null;
while ((ze = in.getNextEntry()) != null) {
if (ze.isDirectory()) {
continue;
} else {
String name = ze.getName();
if (!name.endsWith(".class"))
continue;
name = name.replace('/', '.').replaceAll(".class", "");
System.out.println(name);
}
}
} finally {
in.close();
}
}
sun.tools.jar.Main jartool =
new sun.tools.jar.Main(System.out, System.err, "jar");
jartool.run(new String[]{"-tf","D:/Program Files/AdventNet/CLI/jars/comm.jar"});
}
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;/**
*
* @author ronny_zeng
*
*/
public class SearchClass {
public static void main(String[] args) throws Exception {
String classpath = System.getProperty("java.class.path");
String[] all = classpath.split(";");
for(int i = 0;i<all.length;i++) {
if(all[i].endsWith(".jar")) {
findJar(all[i],"org.apache.struts.action");
} else {
findFile(all[i],"org.apache.struts.action");
}
}
} /**
*
* @param path
* @param packName
* @throws Exception
*/
public static void findFile(String path, String packName) throws Exception {
File file = new File(path + "\\" + packName.replace('.', '\\'));
System.out.println(file.getAbsolutePath());
if (file.exists() && file.isDirectory()) { File[] classes = file.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
if (name.endsWith(".class")) {
System.out.println(name);
return true;
}
return false;
}
});
System.out.println(classes.length);
}
} /**
*
*/
public static void findJar(String jar ,String packName) throws Exception {
ZipInputStream in = new ZipInputStream(new FileInputStream(
new File(jar)));
ZipEntry ze = null; while ((ze = in.getNextEntry()) != null) {
if(ze.getName().startsWith(packName.replace(".","/"))&&ze.getName().endsWith(".class")&&(ze.getName().lastIndexOf("/")==(packName.replace(".","/")+"/").lastIndexOf("/"))) {
System.out.println(ze.getName());
}
}
}}