欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

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

本文實(shí)例為大家分享了java代碼統(tǒng)計(jì)小程序,供大家參考,具體內(nèi)容如下

創(chuàng)新互聯(lián)建站服務(wù)項(xiàng)目包括尼木網(wǎng)站建設(shè)、尼木網(wǎng)站制作、尼木網(wǎng)頁(yè)制作以及尼木網(wǎng)絡(luò)營(yíng)銷(xiāo)策劃等。多年來(lái),我們專(zhuān)注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,尼木網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶(hù)以成都為中心已經(jīng)輻射到尼木省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶(hù)的支持與信任!

可以測(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á)式來(lái)驗(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++;
   //如果遇到"/*",說(shuō)明注釋開(kāi)始了
   comment = true;
  }
  else if (line.startsWith("/*") && line.endsWith("*/")) {
   commentLines++;
  }
  else if (true == comment) {
   commentLines++;
   if (line.endsWith("*/")) {
   comment = false;
   }
  }
  else if(line.startsWith("http://")){
   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();
  }
  }
 }
 }
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

分享名稱(chēng):java實(shí)現(xiàn)代碼統(tǒng)計(jì)小程序
轉(zhuǎn)載來(lái)源:http://chinadenli.net/article20/gjeejo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、網(wǎng)頁(yè)設(shè)計(jì)公司、定制網(wǎng)站、域名注冊(cè)、外貿(mào)網(wǎng)站建設(shè)、面包屑導(dǎo)航

廣告

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

小程序開(kāi)發(fā)