class2srcDecompiler
Posted max_xbw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了class2srcDecompiler相关的知识,希望对你有一定的参考价值。
方法源自: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; } }
以上是关于class2srcDecompiler的主要内容,如果未能解决你的问题,请参考以下文章