标签:finally 一个 over void src catch border put ati
方法源自:https://stackoverflow.com/questions/272535/how-do-i-decompile-java-class-files
功能:给定一个.class文件,得到反编译的源码。
下载后导入工具包:Procyon (https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler)
Demo:
package util; import java.io.StringWriter; public class Decompile { public void main(String[] args) { String classPath = “*.class”; //input path of .class file String src = class2src(classPath); System.out.println(src); } public String class2src(String classPath) { final StringWriter writer = new StringWriter(); String src = ""; try { com.strobel.decompiler.Decompiler.decompile(classPath, new com.strobel.decompiler.PlainTextOutput(writer)); } catch (IllegalArgumentException e) { System.out.println("classpath : " + classPath); } finally { src = writer.toString(); } return src; } }
标签:finally 一个 over void src catch border put ati
原文地址:http://www.cnblogs.com/XBWer/p/7295081.html