Package Iotest;import Java.io.BufferedReader; Import Java.io.File; Import java.io.FileNotFoundException; Import Java.io.FileReader; Import java.io.IOException; Import Java.util.Scanner; public class Cwq {private static int whitelines = 0; private static int commentlines = 0; private static int normallines = 0; public static void Main (string[] args) {file F = new File ("E:\\workspace\\cwqq\\src\\iotest\\cwq.java"); Sumcode (f); public static void Sumcode (file file) {BufferedReader br = null; Boolean comment = false; try {br = new BufferedReader (new FileReader (file)); String line = ""; try {while (line = Br.readline ())! = null) {line = Line.trim (); if (Line.matches ("^[\\s&&[^\\n]]*$")) {whitelines++; } else if (line.sTartswith ("/*") &&!line.endswith ("*/")) {commentlines++; Comment = true; } else if (true = = comment) {commentlines++; if (Line.endswith ("*/")) {comment = false; }} else if (Line.startswith ("//")) {commentlines++; } else {normallines++; }}} catch (IOException e) {e.printstacktrace (); }} catch (FileNotFoundException e) {e.printstacktrace (); } finally {if (BR! = null) {try {System.out.println ("blank line number : "+whitelines); System.out. println ("Number of comment lines:" +commentlines); System.out.println ("Lines of Code:" +normallines); SYSTEM.OUT.PRINTLN ("Total number of rows:" + (Whitelines+commentlines+normallines)); Br.close (); br = NULL; } catch (IOException e) {e.printstacktrace (); } } } } }
Given a source code file (. cs,. java), output the total number of rows in the file, the number of empty lines, the number of comment lines, the number of lines of code