日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

批量删除java注释_怎样批量去掉java文件中的注释

發(fā)布時間:2025/3/21 编程问答 12 豆豆
生活随笔 收集整理的這篇文章主要介紹了 批量删除java注释_怎样批量去掉java文件中的注释 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

展開全部

批量去掉Java文件中的注釋,可以e69da5e887aa3231313335323631343130323136353331333337396231使用正則表達式進行批量操作,代碼如下: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();?//?創(chuàng)建文件夾

}

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();

}

}

《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的批量删除java注释_怎样批量去掉java文件中的注释的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。