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;
       }
    
    }
  • 相关阅读:
    思维导图
    Delphi 之弹出气泡消息提示
    delphi 响应鼠标进入控件消息
    Delphi 获取当前鼠标下的控件内容
    delphi TTBXToolBar 增加外部控件
    delphi button 实现下拉列表
    delphi 设置多屏幕
    电脑双屏改单屏后看不到文件问题的解决
    delphi ListView 设置固定列宽
    数字孪生(Digital twin)
  • 原文地址:https://www.cnblogs.com/lwcode6/p/11528799.html
Copyright © 2011-2022 走看看