求一份统计自己Eclipse的workspace中代码行数的代码。。。
刚学JAVA不久。。想知道自己写代码的量 还请帮忙 --------------------编程问答--------------------你想统计java文件吗?
/**
* @param args
*/
public static void main(String[] args) {
print("E:\\Users\\pc\\workspace");
}
public static void print(String parth){
File file = new File(parth);
File[] files = file.listFiles();
BufferedReader br = null;
for(File f : files){
String absolutePath = f.getAbsolutePath();
if(f.isDirectory()){
print(absolutePath);
}else{
if(absolutePath.endsWith(".java")){
File javaFile = new File(absolutePath);
try {
br = new BufferedReader(new FileReader(javaFile));
int i = 0;
while(br.readLine() != null){
i++;
}
System.out.println(javaFile.getAbsolutePath() + " : 行数" + i);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally{
if(br != null){
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
}
}
--------------------编程问答-------------------- 查这个干吗用的啊? --------------------编程问答-------------------- 试试啊。。JAVA统计我会 主要是注释的正则表达式这块有点烦
补充:Java , Java EE