送分帖
代码以实现统计单独文件和总工程代码的行数,现想要分别统计 工程中JAVA 的代码行数和JSP的代码行数,通过System.out.println( "请输入要统计的文件或目录:\n ");
byte[] buff = new byte[255];
System.in.read(buff);
System.out.println( "请输入要统计的文件类型:\n ");
byte[] buff1 = new byte[255];
System.in.read(buff1);
fileName = new String(buff).trim();
fileExt = new String(buff1).trim();
输入地址和类型(*.JSP或者*.JAVA) 总体代码如下
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.LineNumberReader;
import
java.io.IOException;
import java.io.PrintStream;
/**
* @author wj
*
* 源文件代码行统计工具Java版 :)
*/
public class Clog{
//多文件代码统计汇总结果
private int gcommentLineNum = 0;
private int gcodeAndCommentLinNum = 0;
private int gblankLineNum = 0;
private int gtotalLineNum = 0;
private int gblankAndCommentLinNum = 0;
//单个文件统计信息
private LineNumberReader lReader;
private int commentLineNum = 0;
private int codeAndCommentLinNum = 0;
private int blankLineNum = 0;
private int totalLineNum = 0;
private int blankAndCommentLinNum = 0;
//初始化
private void init()
{
lReader = null;
commentLineNum = 0;
codeAndCommentLinNum = 0;
blankLineNum = 0;
totalLineNum = 0;
blankAndCommentLinNum = 0;
}
/**
* 判断文件类型,并取得此文件
*