//统计src下代码行数
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class Tongji {
public static long val = 0;
public static void main(String[] args) {
// TODO Auto-generated method stub
File path = new File("src");
list(path);
System.out.println(val);
}
public static void list(File path)
{
if(path.isFile() == true)
{
try {
BufferedReader br = new BufferedReader(
new FileReader(path));
String str = br.readLine();
while(str != null)
{
str = str.trim();
if(str.equals("")){
str= br.readLine();
}
else{
val++;
str= br.readLine();
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return;
}else{
File[] files = path.listFiles();
for(int i=0;i<files.length;i++)
{
list(files);
}
}
}
}
|
|