java 統計代碼行數
来源:互联网 发布:js数组按数字大小排序 编辑:程序博客网 时间:2024/06/09 20:23
女朋友回家了,作爲一個無聊的宅男只能自娛自樂,寫點代碼統計下我寫過多少代碼,結果有點失望,沒有想象中的上百萬行-_-
package org.yeshen;import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class CodeCounter {static long CodeLine = 0; public static void main(String[] args) { File srcDir = new File("/home/yeshen/Documents/Folder/cmsmanager"); if(!srcDir.isDirectory()){ return; } File[] fs = srcDir.listFiles(); try { new CodeCounter().Counter(fs); } catch (IOException e) { e.printStackTrace(); } System.out.print("CodeLine:"); System.out.print(CodeLine); } public CodeCounter(){} private void Counter(File[] fs) throws IOException { for(File file:fs){ if(!file.isDirectory() ){ if(file.getName().contains("java")){ File p =new File( file.getParent()); if(!p.exists()){p.mkdirs();} BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"gbk")); String line = br.readLine(); while(line != null){ if(line.trim().length() > 0){ CodeLine ++; } line = br.readLine(); } br.close(); } }else{ Counter(file.listFiles()); } } } }
0 0
- java 統計代碼行數
- java
- JAVA
- JAVA
- JAVA
- java
- Java
- Java
- JAVA:
- java
- java
- java
- java
- Java
- java
- java
- java
- JAVA?
- python ssh到linux
- 浅拷贝和深拷贝
- 神经网络算法与实践
- 小浣熊干脆面
- noip2009靶形数独题解 转自middlesch_nce24的微博http://blog.sina.com.cn/s/blog_5d0d0f450100jm6u.html#
- java 統計代碼行數
- 考驾照学会的那些事
- Linux系统下安装DB2数据库
- mac下找回未保存的office文档
- CET APP
- Kali 2016版本下增强工具open-vm-tools的安装
- 排序算法之插入排序
- 脚本调试
- 倒数问题