首页 > 代码库 > 【class2src】Decompiler

【class2src】Decompiler

方法源自: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 = http://www.mamicode.com/class2src(classPath);"";		try {			com.strobel.decompiler.Decompiler.decompile(classPath, new com.strobel.decompiler.PlainTextOutput(writer));		} catch (IllegalArgumentException e) {			System.out.println("classpath : " + classPath);		} finally {			src = http://www.mamicode.com/writer.toString();>

【class2src】Decompiler