189 8069 5689

java代码总共有多少 java所有代码

如何计算一个JAVAEE项目一共多少行代码

看到你这个问题,感觉蛮有蔽纯意思的,所以写了个递归方法,可以计算出项目答游有多少行清并销代码

创新互联建站自2013年创立以来,先为大厂等服务建站,大厂等地企业,进行企业商务咨询服务。为大厂企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

public class ItemCount

{

private int lineCount;

private int fileCount;

public int getLineCount()

{

return lineCount;

}

public int getFileCount()

{

return fileCount;

}

public static void main(String[] args) throws IOException

{

ItemCount itemCount = new ItemCount();

//path的值就是你的项目路径

String path = "E:\\lucene\\src";

itemCount.getItemLineNum(new File(path));

System.out.println("该项目一共有"+itemCount.getFileCount()+"个java源文件,"+itemCount.getLineCount()+"行代码");

}

//递归

public void getItemLineNum(File path) throws IOException{

if(path.isFile()  path.getName().endsWith(".java")){

BufferedReader br = new BufferedReader(new FileReader(path));

fileCount++;

while(br.readLine()!=null){

lineCount++;

}

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

br.close();

}else if(path.isDirectory()){

File[] listFiles = path.listFiles();

for (File file : listFiles)

{

getItemLineNum(file);

}

}

}

}


网页标题:java代码总共有多少 java所有代码
浏览路径:http://cdxtjz.cn/article/dshoopo.html

其他资讯