删除文件下所有带//的语句,当然也可以添加(/* */),经过验证,还是比较好用的,代码如下:
package cn.how2j.queue;
/**
* @author Alexs
* @date 20181224 11:46:31
* @email alexs_zhan@powermaxtecher.net
* @version V1.0
* @desc
*/
import java.io.File;
import java.io.IOException;
import java.lang.Character.Subset;
import java.util.Collection;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
public class RemoveannotationAllComment {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
File folder = new File("E:/hmickeck05/src");
Collection<File> fs = FileUtils.listFiles(folder,
new String[] { "java" }, true);
for (File f : fs) {
try {
StringBuilder sb = new StringBuilder();
List<String> lines = FileUtils.readLines(f);
for (String line : lines) {
if (line.trim(