问题描述
大家谁有好的反编译工具,推荐下,最近用那个jd-gui-0.3.3.windows,这个版本的工具出来之后总是一堆注释,很烦人,就这样的/* */ package baby.com.controllor.birthdayevent.formbean;/* */ /* */ import javax.servlet.http.HttpServletRequest;/* */ import org.apache.struts.action.ActionErrors;/* */ import org.apache.struts.action.ActionForm;/* */ import org.apache.struts.action.ActionMapping;/* */ import org.apache.struts.upload.FormFile;/* */ 用正则表达式替换,文件很多,很麻烦,所以向各位请教
解决方案
用正则表达式去掉 /* */import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.OutputStream;import java.io.OutputStreamWriter;public class CopyJava {public static void main(String[] args) throws IOException {copy("e:/src", "e:/desc"); // 这里写好源文件夹和目的文件夹}private static void copy(String srcPath, String descPath) throws IOException {copy(new File(srcPath), new File(descPath));}private static void copy(File srcFile, File descFile) throws IOException {if (srcFile.isFile()) { // 文件File parent = descFile.getParentFile();if (!parent.exists()) {parent.mkdirs(); // 创建文件夹}if (srcFile.getName().endsWith(".java")) {copyJava(srcFile, descFile);} else {copyFile(srcFile, descFile);}} else { // 文件夹for (File file : srcFile.listFiles()) {// 相对路径String srcPath = file.getAbsolutePath().substring(srcFile.getAbsolutePath().length());copy(file, new File(descFile.getAbsolutePath() + srcPath));}}}private static void copyJava(File srcFile, File descFile) throws IOException {BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(descFile)));BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(srcFile)));String line;while ((line = br.readLine()) != null) {bw.write(line.replaceFirst("/\* \*/", "")); // 注意这里,如果不行,要适当修改bw.write("n");}br.close();bw.close();}private static void copyFile(File srcFile, File descFile) throws IOException {OutputStream output = new FileOutputStream(descFile);InputStream input = new FileInputStream(srcFile);byte[] buffer = new byte[1024 * 4];int n = 0;while ((n = input.read(buffer)) != -1) {output.write(buffer, 0, n);}input.close();output.close();}}
解决方案二:
jadclipse 与 eclipse结合,我就是这样用的。eclipse中直接安装:http://www.technoetic.com/eclipse/update
解决方案三:
jd-gui的确不错,但好像没有直接去掉这注释的方法可以自己写个小程序,递归替换掉文件中的/* */
解决方案四:
Java Decompiler
解决方案五:
据称这个是最好的反编译工具了结合DJ Java Decompiler、jad一起使用,各有所长