java去注释
来源:互联网 发布:lg18650电池淘宝 编辑:程序博客网 时间:2024/05/29 18:06
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代码加密的尝试
- 测试java类,去注释后的行数
- myeclipse注释,去注释快捷键
- 用regexp_replace去注释
- vim编辑器-多行加注释与去注释
- 蓝桥杯 算法提高 去注释
- Java注释
- java注释
- Java 注释
- java 注释
- java注释
- JAVA注释
- java注释
- Java注释
- java注释
- Java 注释
- 前缀递增和后缀递增区别
- 使用拦截器防止表单重复提交
- Sensor (draft)
- linux内核启动地址的确定
- CharacterEncodingFilter过滤器处理乱码
- java去注释
- Direc3D设备对象
- 标准C++的类型转换符:static_cast、dynamic_cast、reinterpret_cast和const_cast
- javaMD5
- 详解Spring中bean的作用域
- Android中的MotionEvent
- 自定义标签
- MPT612—效率高达98%的太阳能转换芯片
- EJB发布成WebService总结