public class Tongjidaima { Private static int I; // the code number of rows Private static int J; // number of files public static void main (String [] args) throws IOException { File File = new new File ( "F.: \\ eclipsework \ \ Zhansen "); // take several statistical line folder path traverseFiles (file); // call the recursive method to view .java file for statistics the number of rows System.out.println (" the number of written documents: "+ J); System.out.println ( "total number of lines of code written:" + I); } public static void traverseFiles (File File) throws IOException { IF (File.Exists ()!) { // file exists return ; } IF (! file.isDirectory ()) { // determines whether the file String filename = file.getName ( ); iF (filename.endsWith ( "the Java.")) { // determine whether the .java file J ++ ; BufferedReader BufferedReader = new new BufferedReader ( new new FileReader (file)); String String = null ; the while((BufferedReader.readLine = String ()) =! null ) { I ++; // read rows } } the else return ; } File [] Files = File.listFiles (); // read subfolders files or subfolders IF (files == null || files.length == 0 ) { return ; } for (file file2: files) { // If the method is called recursively traverse the file folder traverseFiles (file2); } } }