189 8069 5689

java代码统计工具下载 java代码量如何统计

Java 有什么好的代码行数,注释行数统计工具

package com.syl.demo.test;

公司主营业务:成都网站制作、成都网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联建站是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联建站推出府谷免费做网站回馈大家。

import java.io.*;

/**

* java代码行数统计工具类

* Created by 孙义朗 on 2017/11/17 0017.

*/

public class CountCodeLineUtil {

private static int normalLines = 0; //有效程序行数

private static int whiteLines = 0; //空白行数

private static int commentLines = 0; //注释行数

public static void countCodeLine(File file) {

System.out.println("代码行数统计:" + file.getAbsolutePath());

if (file.exists()) {

try {

scanFile(file);

} catch (IOException e) {

e.printStackTrace();

}

} else {

System.out.println("文件不存在!");

System.exit(0);

}

System.out.println(file.getAbsolutePath() + " ,java文件统计:" +

"总有效代码行数: " + normalLines +

" ,总空白行数:" + whiteLines +

" ,总注释行数:" + commentLines +

" ,总行数:" + (normalLines + whiteLines + commentLines));

}

private static void scanFile(File file) throws IOException {

if (file.isDirectory()) {

File[] files = file.listFiles();

for (int i = 0; i files.length; i++) {

scanFile(files[i]);

}

}

if (file.isFile()) {

if (file.getName().endsWith(".java")) {

count(file);

}

}

}

private static void count(File file) {

BufferedReader br = null;

// 判断此行是否为注释行

boolean comment = false;

int temp_whiteLines = 0;

int temp_commentLines = 0;

int temp_normalLines = 0;

try {

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

String line = "";

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

line = line.trim();

if (line.matches("^[//s[^//n]]*$")) {

// 空行

whiteLines++;

temp_whiteLines++;

} else if (line.startsWith("/*") !line.endsWith("*/")) {

// 判断此行为"/*"开头的注释行

commentLines++;

comment = true;

} else if (comment == true !line.endsWith("*/")) {

// 为多行注释中的一行(不是开头和结尾)

commentLines++;

temp_commentLines++;

} else if (comment == true line.endsWith("*/")) {

// 为多行注释的结束行

commentLines++;

temp_commentLines++;

comment = false;

} else if (line.startsWith("//")) {

// 单行注释行

commentLines++;

temp_commentLines++;

} else {

// 正常代码行

normalLines++;

temp_normalLines++;

}

}

System.out.println(file.getName() +

" ,有效行数" + temp_normalLines +

" ,空白行数" + temp_whiteLines +

" ,注释行数" + temp_commentLines +

" ,总行数" + (temp_normalLines + temp_whiteLines + temp_commentLines));

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} finally {

if (br != null) {

try {

br.close();

br = null;

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

//测试

public static void main(String[] args) {

File file = new File("F:\\myweb");

countCodeLine(file);

}

}

告诉我一个统计java代码量的小工具,非空非注的。

网上有个叫SourceCounter的工具可以统计代码,你可以搜一下,作者的邮箱是boomworks@hotmail.com。我这也有这个工具,需要的话可以留个邮箱,给你发也行。软件大小2.71M

代码统计工具,要支持差异统计,如:代码修改行数、删除行数、新增行数等

我想你要的正是TortoiseSVN,使用方法见

他的代码差异统计功能无庸质疑

另外介绍一个也是统计代码差异的工具:StatSVN

StatSVN能够从Subversion版本库中取得信息,然后生成描述项目开发的各种表格和图表。比如:总代码行数;代码行数的时间线;针对每个开发者的代码行数;开发者的活跃程度;开发者最近所提交的;文件数量;平均文件大小;最大文件;哪个文件是修改最多次数的;目录大小;带有文件数量和代码行数的Repository tree。StatSVN当前版本能够生成一组包括表格与图表的静态HTML文档。

求问怎么统计JAVA代码行数?有什么工具?

源代码行数统计器 1.5

本软件用于统计软件工程源代码行数,

可对指定的子目录下或整个目录树中所有指定类型的源代码文件进行行数统计。


本文标题:java代码统计工具下载 java代码量如何统计
网站网址:http://cdxtjz.cn/article/ddodiec.html

其他资讯