COPY文件,过滤注释.
来源:互联网 发布:装修精美淘宝店 编辑:程序博客网 时间:2024/05/16 18:38
package com.sinosoft.lis.scm.socket;
import java.io.*;
public class FileFitherCopy {
private static File source, target;
private static void copyWithoutCommentsAndBlank(File source, File target) {
try {
BufferedReader br = new BufferedReader(new FileReader(source));
BufferedWriter bw = new BufferedWriter(new FileWriter(target));
String text;
while ((text = br.readLine()) != null) {
if (text.matches("//s*/n?/t*"))
continue;
if (text.matches("//s*/t*.*//.*/n?")) { //处理行注释"//"与代码混合的情况
text = text.split("//")[0];
if ("//s*/t*".equals(text) | "".equals(text))
continue;
}
if (text.startsWith("/*") | text.startsWith("*")
| text.endsWith("*/")) { //处理段落注释"/*...*/",我默认段落注释是不会夹杂在代码中的
continue;
}
System.out.println(text);
bw.write(text);
bw.newLine();
}
bw.close();
} catch (IOException ioException) {
System.err.println("Error!");
}
}
public static void main(String args[]) {
source = new File("d:/Server.java");
target = new File("e:/B.java");
copyWithoutCommentsAndBlank(source, target);
System.out.println("/nFINISH!");
}
}
- COPY文件,过滤注释.
- 个人项目-过滤代码工程文件注释
- 注释过滤
- 注释过滤程序
- 过滤注释的程序
- Perl:过滤注释
- 正则表达式:注释过滤
- 文件Copy
- 文件Copy
- copy文件
- Copy文件
- 文件copy
- copy文件
- 文件COPY
- 文件过滤
- 文件过滤
- 过滤文件
- 文件过滤
- telnet 命令详解
- SQL自动网络备份
- ubuntu stuffs
- FOR XML PATH 语句的应用
- 泛型
- COPY文件,过滤注释.
- C++虚函数表解析(转)
- 简单工厂之Delphi实现
- zoj 2750 Idiomatic Phrases Game
- c++ 多态 虚函数 析构函数 抽象类
- 解决Ubuntu下NetBeans中文乱码的问题
- gridview显示数据和传值
- Apache POI 模块化代码示例
- Oracle 监听器日志格式化