统计代码行数 -凯发k8国际

`

统计代码行数

    博客分类:
  • java

import lombok.extern.slf4j.slf4j;

import org.junit.test;

import org.junit.runner.runwith;

import org.springframework.boot.test.context.springboottest;

import org.springframework.test.context.junit4.springrunner;

 

import java.io.bufferedreader;

import java.io.file;

import java.io.filereader;

@slf4j

@springboottest(classes = telemarketcoreapplication.class)

@runwith(springrunner.class)

public class common {

 

    /**

     * 统计项目代码行数

     */

//    @test

//    public void codecount() throws exception {

//        scanner cin = new scanner(system.in) ;

//        system.out.println("请输入地址:");

//        string path = cin.next() ;

//        codecount machine = new codecount(path) ;

//        machine.caculator();

//        system.out.println(machine.tostring());

//        cin.close();

//    }

    /**

     * 统计项目代码行数

     */

    @test

    public void codecount() throws exception {

        codecount machine = new codecount("f:\\job-vcs\\telemarket-api") ;

        machine.caculator();

        system.out.println(machine.tostring());

    }

 

}

 

class codecount {

    private static int count ; //统计总行数

    private static int countcpp ;//cpp

    private static int countjava ;//java

    private static int countpy ;//python

    private string path ; //用于接收用户输入保存代码的文件夹的路径

    private int reading(string path) throws exception { //该函数用来统计一个代码文件的行数

        filereader reader = new filereader(path) ;

        bufferedreader buffer = new bufferedreader(reader) ;

        int count = 0 ;

        while(buffer.readline()!=null) {

            count ;

        }

        buffer.close() ;

        reader.close() ;

        return count ;

    }

    private void caculate(string nowpath) throws exception{//计数函数

        file nowfile = new file(nowpath) ;

        if (nowfile.isfile()) {

            if (nowpath.endswith(".cpp")) {

                int sum = reading(nowpath) ;

                countcpp = sum ;

                count = sum ;

            }

            else if (nowpath.endswith(".py")) {

                int sum = reading(nowpath) ;

                countpy = sum ;

                count = sum ;

            }

            else if (nowpath.endswith(".java")) {

                int sum = reading(nowpath) ;

                countjava = sum ;

                count = sum ;

            }

            else {

                system.out.println(nowpath ":该类型文件不属于代码文件或该代码文件统计功能正在开发中,敬请期待!");

            }

        }

        else { //如果这个路径表示的是一个文件夹,则执行递归操作

            string []filesset = nowfile.list() ;

            for (string i:filesset ) {

                string newpath = nowpath nowfile.separator i ;//合成路径

                caculate(newpath) ;

            }

        }

    }

    public codecount(string src) {

        path = src ;

    }

    public static int getlinescpp() {

        return countcpp ;

    }

    public static int getlinesjava() {

        return countjava ;

    }

    public static int getlinespy() {

        return countpy ;

    }

    public static int getlines() {

        return count ;

    }

    public void caculator() throws exception { //外界包装

        this.caculate(path) ;

    }

    public string tostring() { //重写tostring方法

        return "统计结果如下:\n"

                "cpp行数:\n" countcpp

                "\njava行数:\n" countjava

                "\npython行数:\n" countpy ;

    }

}

 

分享到:
评论

相关推荐

    可以统计代码行数的插件,测试完全,保证正确,可以统计工程目录,单个文件,多个文件java代码中注释,代码行数

    c#统计代码行数 vs2013编译 可以定义拓展名 包含文件和文件夹

    visual studio和eclipse如何统计代码行数

    用于统计项目的代码行数。在代码中修改路径即可。适用于多种文件格式。

    count lines of code 统计代码行数

    统计代码行数的idea插件,可以很好地将统计的结果分类显示,分成java行数,xml行数,properties行数

    代码行数统计工具,所有项目通用,代码行数统计工具,所有项目通用

    代码行数计算工具 win版 计算代码行数 使用方法看说明.txt 文档

    通过该工具可以方便的统计出自己所写得代码行数,可以选择不同的文件类型来进行统计,exe文件

    用于程序员统计代码行数的工具,使用方便快捷,很快就能给出统计结果,并且可以设置统计的方法和形式,可用于管理程序员的工作量

    可以统计一个或多个文件夹内代码的行数 支持自定义文件扩展名 支持"{","}"识别 如 可设置将 { response.end(); } 视作一行或三行.. 等

    统计代码行数工具kazoeciao.支持各种语言,需要到凯发k8国际娱乐官网入口官网下载插件包. 凯发k8国际娱乐官网入口官网:https://www.vector.co.jp/soft/winnt/prog/se251853.html 「かぞえチャオ!」は、ソフト開発における、規模見積りから生産性評価にまで使え...

    一个统计代码行数的小工具,绿色,支持多种代码格式:xml,vb,c,sql,h,sh,dfm,java,php,asp,txt,jsp,html,等等。

    一个用php做的统计php代码行数的程序

    用java实现统计代码行数,运行程序会统计编程的工作量以及有效代码的行数

    用来统计开发代码的长度,非常的使用,什么程序都可以统计

    统计代码行数

    mylinecounter统计代码行数的工程(递归 工作队列)

    代码行数统计工具,特别好用,可以统计代码的注释行数、空行数、代码有效行数。值得拥有。 代码行数统计工具,特别好用,可以统计代码的注释行数、空行数、代码有效行数。值得拥有。

global site tag (gtag.js) - google analytics
网站地图