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

統(tǒng)計(jì)java工程代碼行數(shù) 怎樣統(tǒng)計(jì)程序代碼行數(shù)

如何計(jì)算一個(gè).java文件的代碼行數(shù)

方法一:

成都創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站建設(shè)、成都網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的井研網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

如果想要通過java代碼的方式來計(jì)算.java文件的行數(shù),可以通過IO來讀取,

BufferedReader的方法readLine()來按行讀取,每讀取一行,行數(shù)+1

方法二:

如果要查看.java文件的代碼行數(shù),

可以使用現(xiàn)成的IDE工具,比如ECLIPSE...

每一行的行號(hào)都有表示出來

eclipse怎么統(tǒng)計(jì)代碼行數(shù)

Eclipse可以方便的統(tǒng)計(jì)工程或文件的代碼行數(shù)。方法如下:

1.首先選中你要統(tǒng)計(jì)的工程,在菜單欄點(diǎn)擊Search,然后點(diǎn)擊File...

2.選中右側(cè)正則表達(dá)式(Regular expression),并在搜索文本框輸入\n

3.在文件名中輸入*或*.java

4.在范圍里選中Enclosing projects

5.在Search窗口就會(huì)顯示出項(xiàng)目或文件的代碼行數(shù)

求問怎么統(tǒng)計(jì)JAVA代碼行數(shù)?有什么工具?

源代碼行數(shù)統(tǒng)計(jì)器 1.5

本軟件用于統(tǒng)計(jì)軟件工程源代碼行數(shù),

可對指定的子目錄下或整個(gè)目錄樹中所有指定類型的源代碼文件進(jìn)行行數(shù)統(tǒng)計(jì)。

如何統(tǒng)計(jì)某目錄下的java文件代碼行數(shù)

可以自己寫一個(gè)小程序,遍歷每個(gè)文件;

如果是*.java就記錄該文件的行數(shù),依次累加。

Java 有什么好的代碼行數(shù),注釋行數(shù)統(tǒng)計(jì)工具

package com.syl.demo.test;

import java.io.*;

/**

* java代碼行數(shù)統(tǒng)計(jì)工具類

* Created by 孫義朗 on 2017/11/17 0017.

*/

public class CountCodeLineUtil {

private static int normalLines = 0; //有效程序行數(shù)

private static int whiteLines = 0; //空白行數(shù)

private static int commentLines = 0; //注釋行數(shù)

public static void countCodeLine(File file) {

System.out.println("代碼行數(shù)統(tǒng)計(jì):" + file.getAbsolutePath());

if (file.exists()) {

try {

scanFile(file);

} catch (IOException e) {

e.printStackTrace();

}

} else {

System.out.println("文件不存在!");

System.exit(0);

}

System.out.println(file.getAbsolutePath() + " ,java文件統(tǒng)計(jì):" +

"總有效代碼行數(shù): " + normalLines +

" ,總空白行數(shù):" + whiteLines +

" ,總注釋行數(shù):" + commentLines +

" ,總行數(shù):" + (normalLines + whiteLines + commentLines));

}

private static void scanFile(File file) throws IOException {

if (file.isDirectory()) {

File[] files = file.listFiles();

for (int i = 0; i files.length; i++) {

scanFile(files[i]);

}

}

if (file.isFile()) {

if (file.getName().endsWith(".java")) {

count(file);

}

}

}

private static void count(File file) {

BufferedReader br = null;

// 判斷此行是否為注釋行

boolean comment = false;

int temp_whiteLines = 0;

int temp_commentLines = 0;

int temp_normalLines = 0;

try {

br = new BufferedReader(new FileReader(file));

String line = "";

while ((line = br.readLine()) != null) {

line = line.trim();

if (line.matches("^[//s[^//n]]*$")) {

// 空行

whiteLines++;

temp_whiteLines++;

} else if (line.startsWith("/*") !line.endsWith("*/")) {

// 判斷此行為"/*"開頭的注釋行

commentLines++;

comment = true;

} else if (comment == true !line.endsWith("*/")) {

// 為多行注釋中的一行(不是開頭和結(jié)尾)

commentLines++;

temp_commentLines++;

} else if (comment == true line.endsWith("*/")) {

// 為多行注釋的結(jié)束行

commentLines++;

temp_commentLines++;

comment = false;

} else if (line.startsWith("http://")) {

// 單行注釋行

commentLines++;

temp_commentLines++;

} else {

// 正常代碼行

normalLines++;

temp_normalLines++;

}

}

System.out.println(file.getName() +

" ,有效行數(shù)" + temp_normalLines +

" ,空白行數(shù)" + temp_whiteLines +

" ,注釋行數(shù)" + temp_commentLines +

" ,總行數(shù)" + (temp_normalLines + temp_whiteLines + temp_commentLines));

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} finally {

if (br != null) {

try {

br.close();

br = null;

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

//測試

public static void main(String[] args) {

File file = new File("F:\\myweb");

countCodeLine(file);

}

}

新聞標(biāo)題:統(tǒng)計(jì)java工程代碼行數(shù) 怎樣統(tǒng)計(jì)程序代碼行數(shù)
標(biāo)題來源:http://chinadenli.net/article10/hgdigo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、營銷型網(wǎng)站建設(shè)手機(jī)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、小程序開發(fā)外貿(mào)建站

廣告

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

手機(jī)網(wǎng)站建設(shè)