zoukankan      html  css  js  c++  java
  • 查看工程里有多少行java代码

    /**
     * @Classname CustBankcardServiceImpl
     * @Description 计算项目代码量(行数)
     * @Date 2019/11/04 14:24
     * @Created by lw
     */
    public class CalcCodeNum {
    
       public static void main(String[] args) throws IOException {
          // java代码
          int java_num = getProjectFileNumber(new File("D:\lw\work_space\yxhd\lcs\lcs-service\src\main\java\io\kyoto"), ".java");
    
          // resource目录
          // xml
          int xml_num = getProjectFileNumber(new File("D:\lw\work_space\yxhd\lcs\lcs-service\src\main"), ".xml");
          // properties
          int properties_num = getProjectFileNumber(new File("D:\lw\work_space\yxhd\lcs\lcs-service\src\main"), ".properties");
          System.out.println("java:" + java_num);
          System.out.println("xml:" + xml_num);
          System.out.println("properties:" + properties_num);
          System.out.println("total:" + (java_num + xml_num + properties_num));
       }
    
       /**
         * 递归获取文件中代码行数
         * */
       private static int getProjectFileNumber(File file, String endsWith) throws IOException{
          int number = 0;
          if (file.exists()) {
             if (file.isDirectory()) {
                for (File subFile : file.listFiles()) {
                   number += getProjectFileNumber(subFile, endsWith);
                }
             } else if (file.isFile() && file.getName().endsWith(endsWith)) {
                BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
                while (br.readLine() != null) {
                   number += 1;
                }
             } else {
                System.out.println("===" + file.getAbsolutePath());
             }
          }
          return number;
       }
    
    }
  • 相关阅读:
    Spark完成wordCount
    Spark介绍
    分库分表介绍
    rpc学习
    xgboost应用
    ElasticSearch 批量增加索引
    乡愁
    java futureTask的使用
    ElasticSearch 例子
    Matlab实现线性回归和逻辑回归: Linear Regression & Logistic Regression
  • 原文地址:https://www.cnblogs.com/lwcode6/p/11528799.html
Copyright © 2011-2022 走看看