<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    vjame

    優化代碼是無止境的
    隨筆 - 65, 文章 - 9, 評論 - 26, 引用 - 0
    數據加載中……

    代碼統計

    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 whiteLines = 0;
        
        
    public static void main(String[] args) {
            File f 
    = new File("D:\\share\\JavaProjects\\TankWar1.9.11\\src");
            File[] codeFiles 
    = f.listFiles();
            
    for(File child : codeFiles){
                
    if(child.getName().matches(".*\\.java$")) {
                    parse(child);
                }
            }
            
            System.out.println(
    "normalLines:" + normalLines);
            System.out.println(
    "commentLines:" + commentLines);
            System.out.println(
    "whiteLines:" + 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 (line.startsWith("/*"&& line.endsWith("*/")) {
                        commentLines 
    ++;
                    } 
    else if (true == comment) {
                        commentLines 
    ++;
                        
    if(line.endsWith("*/")) {
                            comment 
    = false;
                        }
                    } 
    else if (line.startsWith("//")) {
                        commentLines 
    ++;
                    } 
    else {
                        normalLines 
    ++;
                    }
                }
            } 
    catch (FileNotFoundException e) {
                e.printStackTrace();
            } 
    catch (IOException e) {
                e.printStackTrace();
            } 
    finally {
                
    if(br != null) {
                    
    try {
                        br.close();
                        br 
    = null;
                    } 
    catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }

    }

    posted on 2009-02-09 13:23 lanjh 閱讀(474) 評論(5)  編輯  收藏 所屬分類: Java App

    評論

    # re: 代碼統計  回復  更多評論   

    這個算法比較簡單,而且沒有考慮折行的問題,難能可貴的是是自己實現這個算法,鼓勵了
    2009-02-10 11:13 | jeasonzhao

    # Pharmacy  回復  更多評論   

    Hi. In the future I'm going to keep here links to their sites. But I do not worry about the sites where my link is removed. So if you do not want to see a mountain of links, simply delete this message. After 2 weeks, I will come back and check.
    2009-05-12 01:53 | Taddeo

    # Wall clock  回復  更多評論   

    Hello everyone. Speak when you are angry--and you will make the best speech you'll ever regret.
    I am from Egypt and learning to write in English, please tell me right I wrote the following sentence: "Synthroid and phentermine, tramadol cheap price, phentermine with vit injection, phentermine no prescription online consultation, addition in order phentermine."

    Thank you so much for your future answers :-(. Zaccheus.
    2009-05-15 19:25 | Zaccheus

    # Payday LOan  回復  更多評論   

    Give please. Use what you have to run toward your best - that's how I now live my life.
    I am from Czech and also now'm speaking English, give please true I wrote the following sentence: "Progesterone, synthroid, flagyli I pulses azith m w f sun, estriol, progesterone, synthroid, and pulsing w flagyli."

    Thanks for the help 8), Doreen.
    2009-05-19 11:45 | Doreen

    # Turbo Tax  回復  更多評論   

    Hi everyone. I love you so much. Great place to visit. Help me! Can not find sites on the: Turbo Tax. I found only this - <a href="http://turbo-tax.biz">turbo tax</a>. Buy cytomel liothyronine sodium online. Synthroid too high synthroid and cholesterol soon after starting synthroid taken with adderall tramadol, he began to. With respect ;-), Rosalyn from Jamaica.
    2009-05-24 18:55 | Rosalyn
    主站蜘蛛池模板: 亚洲综合丁香婷婷六月香| 香蕉视频亚洲一级| 国产在线观看免费观看不卡| 亚洲综合在线一区二区三区 | 黄色视频在线免费观看| 亚洲欧洲第一a在线观看| 成人午夜免费福利| 手机看片国产免费永久| 亚洲国产精品成人精品小说| 国产91在线免费| 91成人在线免费视频| 亚洲国产AV一区二区三区四区 | 亚洲av无码无在线观看红杏| 成人在线免费观看| 久草福利资源网站免费| 亚洲日本中文字幕天天更新| 亚洲国产成人私人影院| 吃奶摸下高潮60分钟免费视频| 免费无遮挡无码永久视频| 日韩色日韩视频亚洲网站| 亚洲网站在线播放| 国产乱辈通伦影片在线播放亚洲| 18禁免费无码无遮挡不卡网站| 黄色视频在线免费观看| 亚洲经典千人经典日产| 亚洲精品电影天堂网| 国产亚洲精品福利在线无卡一| 成年18网站免费视频网站| 国产一区二区三区免费| 免费看内射乌克兰女| 亚洲高清有码中文字| 亚洲国产精品久久66| 精品国产亚洲一区二区在线观看 | 91精品国产亚洲爽啪在线观看| 亚洲国产精品日韩专区AV| 三年片在线观看免费大全| 久久久久国产精品免费网站| 一级做a爰片性色毛片免费网站 | 亚洲视频免费在线播放| 特级做A爰片毛片免费看无码| 无码天堂亚洲国产AV|