tobly916 2011-01-10 10:02
浏览 248
已采纳

java反编译工具

大家谁有好的反编译工具,推荐下,最近用那个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;
/
*/
用正则表达式替换,文件很多,很麻烦,所以向各位请教

  • 写回答

5条回答 默认 最新

  • lang_shao 2011-01-11 10:28
    关注

    用正则表达式去掉 /* */
    [code="java"]
    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();
    }
    

    }
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码