首页 > 其他 > 详细

【class2src】Decompiler

时间:2017-08-06 16:31:20      阅读:241      评论:0      收藏:0      [点我收藏+]

方法源自: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;
	}
}

【class2src】Decompiler

原文:http://www.cnblogs.com/XBWer/p/7295081.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!