利用java小工具-----统计项目代码量(二)

2014-11-24 08:51:32 · 作者: · 浏览: 1
一行中/*与*/是否成对出现
int count1 = 0; www.2cto.com
int count2 = 0;
Pattern p = Pattern.compile("/\\*");
Matcher m = p.matcher(line);
while (m.find()) {
count1++;
}
p = Pattern.compile("\\*/");
m = p.matcher(line);
while (m.find()) {
count2++;
}
return (count1 == count2);
}

}
作者:ll136078