只能删除java文件中每一行中第一次出现的/**/注释 对java反编译以后的代码注释删除工作有帮助
删除java单行注释
01 |
import java.io.BufferedReader;
|
02 |
import java.io.BufferedWriter;
|
04 |
import java.io.FileOutputStream;
|
05 |
import java.io.FileReader;
|
06 |
import java.io.FileWriter;
|
07 |
import java.io.OutputStreamWriter;
|
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);
|
17 |
public static void print(File f) throws Exception {
|
20 |
if (f.isDirectory()) {
|
21 |
String st2 = f.toString().replace( "D:\\" , "E:\\" );
|
22 |
File fc = new File(st2);
|
24 |
File[] fileArray = f.listFiles();
|
25 |
if (fileArray != null ) {
|
26 |
for ( int i = 0 ; i < fileArray.length; i++) {
|
32 |
// System.out.println(f);
|
33 |
if (f.getName().endsWith( ".java" )) {
|
34 |
String stfile = f.toString().replace( "D:\\" , "E:\\" );
|
36 |
FileOutputStream fileOutputStream = new FileOutputStream(
|
38 |
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
|
39 |
fileOutputStream, "UTF-8" ); // 或者"GBK"
|
40 |
BufferedWriter bw = new BufferedWriter(outputStreamWriter);
|
42 |
// BufferedWriter bw=new BufferedWriter(new
|
43 |
// FileWriter(stfile));
|
44 |
String str = DelCommentsInJava.fun1(f);
|
50 |
String out = f.toString().replace( "D:\\" , "E:\\" );
|
51 |
BufferedReader reader = new BufferedReader(
|
53 |
StringBuilder content = new StringBuilder();
|
55 |
while ((tmp = reader.readLine()) != null ) {
|
59 |
String target = content.toString();
|
60 |
BufferedWriter bw = new BufferedWriter( new FileWriter(out));
|
|
请发表评论