第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

正則表達(dá)式統(tǒng)計(jì)怎么統(tǒng)計(jì)空行、代碼行、注釋

正則表達(dá)式統(tǒng)計(jì)怎么統(tǒng)計(jì)空行、代碼行、注釋

fenkapian 2016-11-11 19:28:53
用這個(gè)程序測(cè)代碼行、空行和注釋行,老是顯示都為0行,麻煩看看哪里錯(cuò)了啊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 codeLines = 0; static long commentLines = 0; static long whiteLines = 0; public static void main(String[] args) { File f = new File("D:\\Workspaces\\MyEclipse Professional 2014\\DOMTest\\src\\question"); File [] codeFiles = f.listFiles(); for (File file : codeFiles) { if (file.getName().matches(".* \\.java$")) { parse(file); } } System.out.println(codeLines); System.out.println(commentLines); System.out.println(whiteLines); } private static void parse(File f) { BufferedReader br = null; boolean comment = false; try { br = new BufferedReader(new FileReader(f)); String line = ""; while ((line = br.readLine()) != null) { line = line.trim(); if (line.matches("^[\\s&&[^\\n]]*$")) { whiteLines++; } else if (line.startsWith("/*") && line.endsWith("*/")) { commentLines++; comment = true; } else if (true == comment) { commentLines ++; if (line.endsWith("*/")) { comment = false; } } else { codeLines ++; } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); br = null; } catch (IOException e) { e.printStackTrace(); } } } }}
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 1960 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)