import java.io.*;public class Check {
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:空間域名、網(wǎng)站空間、營(yíng)銷(xiāo)軟件、網(wǎng)站建設(shè)、臺(tái)前網(wǎng)站維護(hù)、網(wǎng)站推廣。
public static void main (String[] args) throws IOException{
check("D:/MyEclipse/java/src/my/Check.java");//這里的字符串是你要統(tǒng)計(jì)的文件的路徑,你自己填寫(xiě)
} public static void check (String s) throws IOException{
int all = 0, empty = 0, describe = -1, i = 0;
String str = null;
File f = new File(s);
BufferedReader br = new BufferedReader (new FileReader(f));
str = br.readLine();
while(str != null){
all++;
if(str.trim().equals("")) empty++;
if(str.contains("http://")) describe++;
if(str.contains("/*")){
while(!str.contains("*/")){
i++;
all++;
describe++;
str = br.readLine();
}
}
str = br.readLine();
}
System.out.println("文件物理總行數(shù)為:" + all);//;;klj
System.out.println("文件中空行數(shù)為:" + empty);//hkk
System.out.println("文件注釋行數(shù)為:" + describe);
System.out.println("文件非注釋行數(shù)為:" + (all - i));
/*asdfdsff
* sdasadfsf//fg
* asdfsdf//dsfg
* asdf
*/
}
}以上是代碼,我在我的機(jī)子上實(shí)現(xiàn)了,希望能幫到你!我也是JAVA菜鳥(niǎo),希望有高手能更好地解答
源代碼行數(shù)統(tǒng)計(jì)器 1.5
本軟件用于統(tǒng)計(jì)軟件工程源代碼行數(shù),
可對(duì)指定的子目錄下或整個(gè)目錄樹(shù)中所有指定類(lèi)型的源代碼文件進(jìn)行行數(shù)統(tǒng)計(jì)。
public class Test {\x0d\x0a\x0d\x0a public static void main(String[] args) throws Exception{\x0d\x0a Scanner input=new Scanner(System.in);\x0d\x0a System.out.println("請(qǐng)輸入路徑");\x0d\x0a String path=input.next();\x0d\x0a int charNum= 0 ;\x0d\x0a int wordsNum= 0;\x0d\x0a int lineNum = 0;\x0d\x0a InputStreamReader isr = new InputStreamReader(new FileInputStream(path)); \x0d\x0a BufferedReader br = new BufferedReader(isr);\x0d\x0a while( br.read()!= -1){\x0d\x0a String s = br.readLine();\x0d\x0a charNum+=s.length();\x0d\x0a wordsNum +=s.split(" ").length;\x0d\x0a lineNum ++; \x0d\x0a }\x0d\x0a isr.close();//關(guān)閉\x0d\x0a System.out.println("字符數(shù):"+charNum+"\t單詞數(shù):"+wordsNum+"行 數(shù):"+lineNum); \x0d\x0a\x0d\x0a }\x0d\x0a}
網(wǎng)站標(biāo)題:java代碼行數(shù)統(tǒng)計(jì)腳本 java怎么統(tǒng)計(jì)個(gè)數(shù)
網(wǎng)頁(yè)鏈接:http://www.chinadenli.net/article6/dosiiog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、微信小程序、標(biāo)簽優(yōu)化、Google、定制開(kāi)發(fā)、服務(wù)器托管
聲明:本網(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í)需注明來(lái)源: 創(chuàng)新互聯(lián)