【Java】计算你写了多少行代码,自动去注释版

之前学IO流,写了一个一段小代码,用来计算纯净代码的行数。去注释去空格

import java.io.*;

/**
 * 去除注释后的代码行数,去除startWith"/"," *","(空字符,表示换行,用equals)"
 */
public class TestPureLine {
   
    public static void main(String[] args) {
   
        //1.File对象封装路径
        //之前项目的代码行数
        File path = new File("D:\\IDEA\\EclipseWorkspace");
        System.out.println(getPureLine(path));//22293精简以后的数量:15331
        //现在项目的代码行数
        File nowPath = new File("D:\\IDEA\\workspace");
        System.out.println(getPureLine(nowPath));//代码8029,精简以后:3216
        //一个文件的测试
        File testPath = new File("D:\\IDEA\\workspace\\test1");
        System.out.println(getPureLine(testPath));//13
    }

    /**
     * 去除注释后的代码行数
     *
     * @param path
     * @return
     */
    private static Integer getPureLine(File path) {
   
        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值