统计你写的java代码行数

2014-11-04 16:30:11 · 作者: · 浏览: 48

  import java.io.BufferedReader;


  import java.io.File;


  import java.io.FileNotFoundException;


  import java.io.FileReader;


  import java.io.IOException;


  /**


  *


  * @author LC


  *


  */


  public class SumJavaCode {


  static long normalLines = 0; // 空行


  static long commentLines = 0; // 注释行


  static long whiteLines = 0; // 代码行


  public static void main(String[] args) {


  SumJavaCode sjc = new SumJavaCode();


  File f = new File(“D:\\spring-framework-2.0-with-dependencies\\spring-framework-2.0″); //目录


  System.out.println(f.getName());


  sjc.treeFile(f);


  System.out.println(“空行:” + normalLines);


  System.out.println(“注释行:” + commentLines);


  System.out.println(“代码行:” + whiteLines);


  }


  /**


  * 查找出一个目录下所有的.java文件


  *


  * @param f 要查找的目录


  */