删除反编译工具生成的/* 1 */

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.InputStreamReader;
import java.io.OutputStreamWriter;

/**
 * 删除项目中
 * 
 * @author Sheamus
 *
 */
public class Delete {
    
    //static String tartgetDir = "D:\\";
    static String tartgetDir = "D:\\Test1\\itjds_server\\";
    
    //static String sourceDir = "C:\\Users\\Sheamus\\Desktop\\";
    static String sourceDir = "D:\\Test\\itjds_server\\";
    
    //static String projectName = "itjdsTest";
    static String projectName = "src";
    
    static String encoding = "utf-8";
    
    public static void main(String[] args) {
        //C:\\Users\\Sheamus\\Desktop\\itjds_org (项目路径信息)
        
        //源
        String sourcePath = sourceDir + projectName;
        
        refreshFileList(sourcePath);
    }

    public static void refreshFileList(String sourcePath) {
        File dir = new File(sourcePath);
        File[] files = dir.listFiles();
        
        if (files == null)
        {
            System.out.println("该目录下没有任何一个文件!");
            return;
        }
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                
                //拼接路径
                String absolutePath = files[i].getAbsolutePath();
                String replace = absolutePath.replace(sourceDir, tartgetDir);
                
                //System.out.println(replace);
                
                File repFile = new File(replace);
                //创建文件夹
                if(!repFile.exists()) {
                    repFile.mkdirs();
                }
                refreshFileList(files[i].getAbsolutePath());
            }else {
                String strFileName = files[i].getAbsolutePath();
//                if(strFileName.endsWith(".java")){
                    //拼接路径
                    String replace = strFileName.replace(sourceDir, tartgetDir);
                    
                    //System.out.println(replace);
                    
                    File repFile = new File(replace);
                    
                    if(!repFile.exists())    
                    {    
                        try {    
                            repFile.createNewFile();    
                        } catch (IOException e) {    
                            // TODO Auto-generated catch block    
                            e.printStackTrace();    
                        }    
                    }    
                    
                    InputStreamReader read = null;
                    BufferedReader bufferedReader = null;
                    OutputStreamWriter out = null;
                    BufferedWriter writer = null;
                    
                    try {
                        read = new InputStreamReader(new FileInputStream(files[i]),encoding);
                        bufferedReader = new BufferedReader(read);
                        String lineTxt = null;
                        
                        out = new OutputStreamWriter(new FileOutputStream(repFile),encoding);
                        writer = new BufferedWriter(out);
                        
                        while((lineTxt = bufferedReader.readLine()) != null){
                            
                            if(lineTxt.startsWith("/*") && lineTxt.contains("*/") ) {
                                String substring = lineTxt.substring(lineTxt.indexOf("*/") + 2);
                                writer.append(substring+"\n");
                                writer.flush();
                            } else {
                                writer.append(lineTxt + "\n");
                                writer.flush();
                            }
                            
                            /*if(lineTxt.startsWith("/* Location:") || lineTxt.startsWith(" * Qualified Name:") || lineTxt.startsWith(" * JD-Core Version:")||) {
                                
                            }*/
                            
                        }

                    } catch (Exception e) {
                        System.out.println("读取文件内容出错");
                        e.printStackTrace();
                    }finally{
                        
                        if(writer != null) {
                            try {
                                writer.close();
                            } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                        
                        if(out != null) {
                            try {
                                out.close();
                            } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                        
                        if(bufferedReader != null) {
                            try {
                                bufferedReader.close();
                            } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                        
                        if(read != null) {
                            try {
                                read.close();
                            } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                        
                    }
//                }
            }
        }
    }
}


转载于:https://my.oschina.net/Sheamus/blog/648658

dnSpy中文版是一款net程序反编译工具,可以对net程序进行反编译,还有替代库文档的功能,如果遇到了代码丢失或者损坏的情况,可以直接恢复,有需要的赶快下载吧! 1、无需设置 由于它是一个便携式工具,它不需要您将其安装在目标计算机上,因为只需拆包其存档并启动可执行文件即可完全访问其功能。 您还可以从可移动存储介质(如USB闪存驱动器或外部HDD)运行它。此外,它不会修改系统中的注册表项,也不会在您的PC上生成其他文件文件夹,但未经您的明确许可。 2、综合界面 dnSpy配备了一个时尚,全面的用户界面,包含广泛的有用功能,它们整齐地组织在主窗口的标准菜单中。 更重要的是,它具有标准配置窗口,您可以在其中调整各种组件的设置,如其反编译器,调试器或十六进制编辑器,但也可以修改显示或其他参数。 3、.NET反汇编程序 如果您需要一个高效的工具,可以通过为您提供各种有用的工具来帮助您反编译.NET程序集,您可以转到dnSpy。它配有一个反编译器,一个调试器,一个十六进制编辑器和一个程序集编辑器,让你以有效的方式处理程序集。 主窗口附带了一个Assembly Explorer窗格,您可以在其中访问所需程序集的树视图。您可以通过从计算机指定适当的文件或使用“从GAC打开”选项打开程序集,该选项为您提供全局程序集缓存中可用的条目列表。 4、.NET程序集的可靠反向工程工具 所有考虑的事情,dnSpy是一个方便的应用程序,使您能够以有效的方式逆向工程.NET程序集,为您提供广泛的有用工具,包括反编译器,程序集编辑器和调试器。它不需要安装,具有全面,平滑的用户界面,并为您提供了一个标准配置窗口,您可以在其中调整各种组件的设置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值