java如何實(shí)現(xiàn)代碼統(tǒng)計(jì)小程序

這篇文章主要介紹了java如何實(shí)現(xiàn)代碼統(tǒng)計(jì)小程序,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

站在用戶的角度思考問題,與客戶深入溝通,找到秀嶼網(wǎng)站設(shè)計(jì)與秀嶼網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名申請(qǐng)、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋秀嶼地區(qū)。

具體內(nèi)容如下

可以測(cè)試每周你的工作量

package rexExp; import java.io.BufferedReader;import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException; public class CodeCounter { //三個(gè)靜態(tài)變量存儲(chǔ)行數(shù) static long normalLines = 0; static long commentLines = 0; static long whileLines = 0;  public static void main(String[] args) { String pathname = "E:\\testeclipseworkspace\\JavaLearn\\src\\collection"; File file = new File(pathname); File[] codeFiles = file.listFiles();//找到文件夾下面的所有子文件 //文件必須是以.java結(jié)尾,用正則表達(dá)式來驗(yàn)證 for(File child : codeFiles){  if (child.getName().matches(".*\\.java$")) {  parse(child);  } }   System.out.println("normalLines:" + normalLines); System.out.println("commentLines:" + commentLines); System.out.println("whileLines:" + whileLines);  }  private static void parse(File file) { BufferedReader bReader = null; boolean comment = false; try {  bReader = new BufferedReader(new FileReader(file));  //讀其中的每一行  String line = "";  while((line=bReader.readLine()) != null){  line = line.trim();//去掉首尾空格  //統(tǒng)計(jì)空行的行數(shù)  if (line.matches("^[\\s&&[^\\n]]*$")) {   whileLines++;  }  //統(tǒng)計(jì)注釋的行數(shù)  else if (line.startsWith("/*") && !line.endsWith("*/")) {   commentLines++;   //如果遇到"/*",說明注釋開始了   comment = true;  }  else if (line.startsWith("/*") && line.endsWith("*/")) {   commentLines++;  }  else if (true == comment) {   commentLines++;   if (line.endsWith("*/")) {   comment = false;   }  }  else if(line.startsWith("//")){   commentLines++;  }  else {   normalLines++;  }  } } catch (FileNotFoundException e) {  e.printStackTrace(); } catch (IOException e) {  e.printStackTrace(); }finally {  if (bReader != null) {  try {   bReader.close();  } catch (IOException e) {   e.printStackTrace();  }  } } }}

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“java如何實(shí)現(xiàn)代碼統(tǒng)計(jì)小程序”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!

標(biāo)題名稱:java如何實(shí)現(xiàn)代碼統(tǒng)計(jì)小程序
當(dāng)前鏈接:http://muchs.cn/article18/pdggdp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、虛擬主機(jī)、網(wǎng)站改版、外貿(mào)建站網(wǎng)站營(yíng)銷、軟件開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計(jì)