bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

java實現代碼統計小程序

本文實例為大家分享了java代碼統計小程序,供大家參考,具體內容如下

創新互聯建站服務項目包括尼木網站建設、尼木網站制作、尼木網頁制作以及尼木網絡營銷策劃等。多年來,我們專注于互聯網行業,利用自身積累的技術優勢、行業經驗、深度合作伙伴關系等,向廣大中小型企業、政府機構等提供互聯網行業的解決方案,尼木網站推廣取得了明顯的社會效益與經濟效益。目前,我們服務的客戶以成都為中心已經輻射到尼木省份的部分城市,未來相信會繼續擴大服務區域并繼續獲得客戶的支持與信任!

可以測試每周你的工作量

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 {
 //三個靜態變量存儲行數
 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結尾,用正則表達式來驗證
 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();//去掉首尾空格
  //統計空行的行數
  if (line.matches("^[\\s&&[^\\n]]*$")) {
   whileLines++;
  }
  //統計注釋的行數
  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("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();
  }
  }
 }
 }
}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持創新互聯。

分享名稱:java實現代碼統計小程序
轉載來源:http://vcdvsql.cn/article20/gjeejo.html

成都網站建設公司_創新互聯,為您提供微信小程序網頁設計公司定制網站域名注冊外貿網站建設面包屑導航

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

小程序開發