• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

用于删除java注释的小程序

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
只能删除java文件中每一行中第一次出现的/**/注释
对java反编译以后的代码注释删除工作有帮助

删除java单行注释

01 import java.io.BufferedReader;
02 import java.io.BufferedWriter;
03 import java.io.File;
04 import java.io.FileOutputStream;
05 import java.io.FileReader;
06 import java.io.FileWriter;
07 import java.io.OutputStreamWriter;
08  
09 class ListAllFirst {
10     public static void main(String[] args) throws Exception {
11         String fileName = "D:\\dto.syntheticalstatistics.src\\com\\sysway\\boss\\dto\\report\\statistics";
12         File f = new File(fileName);
13         print(f);
14  
15     }
16  
17     public static void print(File f) throws Exception {
18  
19         if (f != null) {
20             if (f.isDirectory()) {
21                 String st2 = f.toString().replace("D:\\", "E:\\");
22                 File fc = new File(st2);
23                 fc.mkdirs();
24                 File[] fileArray = f.listFiles();
25                 if (fileArray != null) {
26                     for (int i = 0; i < fileArray.length; i++) {
27                         // 递归调用
28                         print(fileArray[i]);
29                     }
30                 }
31             } else {
32                 // System.out.println(f);
33                 if (f.getName().endsWith(".java")) {
34                     String stfile = f.toString().replace("D:\\", "E:\\");
35  
36                     FileOutputStream fileOutputStream = new FileOutputStream(
37                             stfile);
38                     OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
39                             fileOutputStream, "UTF-8");// 或者"GBK"
40                     BufferedWriter bw = new BufferedWriter(outputStreamWriter);
41  
42                     // BufferedWriter bw=new BufferedWriter(new
43                     // FileWriter(stfile));
44                     String str = DelCommentsInJava.fun1(f);
45                     bw.write(str);
46                     bw.flush();
47                     bw.close();
48  
49                 } else {
50                     String out = f.toString().replace("D:\\", "E:\\");
51                     BufferedReader reader = new BufferedReader(
52                             new FileReader(f));
53                     StringBuilder content = new StringBuilder();
54                     String tmp = null;
55                     while ((tmp = reader.readLine()) != null) {
56                         content.append(tmp);
57                         content.append("\n");
58                     }
59                     String target = content.toString();
60                     BufferedWriter bw = new BufferedWriter(new FileWriter(out));
61                     bw.write(target);
62                     bw.flush();
63                     bw.close();
64                     reader.close();
65                 }
66             }
67         }
68     }
69  
70 }

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
小程序 之裁剪上传图片发布时间:2022-07-18
下一篇:
小程序for循环给里面单独的view加单独的样式发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap