成都创新互联网站制作重庆分公司

去除java代码注释 java废弃注解

如何批量去掉Java的注释

多行注释,将鼠标移到被注释内容,按ctrl+shift+\可以取消注释

长葛网站制作公司哪家好,找成都创新互联公司!从网页设计、网站建设、微信开发、APP开发、自适应网站建设等网站项目制作,到程序开发,运营维护。成都创新互联公司从2013年开始到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联公司

单行注释,按ctrl+/可以取消注释

Java类中如何去除注释

能直接删去的阿。 把注释全部圈起来然后按Backspace键就可以删除了

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

批量去掉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();  

}  

}


文章名称:去除java代码注释 java废弃注解
URL地址:http://cxhlcq.com/article/dodjjsh.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部