📄 statthread.java~82~
字号:
package stat;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author unascribed * @version 1.0 */import java.io.*;import java.util.*;public class statThread extends Engine{ private String fileName = ""; private int lineTotal = 0; private int logicTotal = 0; private int remarkTotal = 0; public statThread(String f) { super("statThread"); setDaemon(true); fileName = f; } public void run(){ Vector txtContent = new Vector(); File file = new File(fileName); if(file.canRead() && file.exists()){ try{ FileReader fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); String line = ""; while((line = br.readLine())!= null ){ System.out.println(line.trim() ); txtContent.addElement(line.trim()); } br.close() ; fr.close() ; file = null; //Decode Text DecodeMutilLine(txtContent); //End Decode Text }catch(Exception e){ System.out.println("Exception in statThread :"+e.toString() ); System.out.println("filename is : "+fileName); } } System.out.println(lineTotal+" "+logicTotal+" "+remarkTotal); } private void DecodeLine (Vector v){ for(int i = 0;i<v.size() ;i++){ String lineStr = (String)v.get(i); lineStr.trim() ; lineTotal ++; System.out.println("//rong"+lineStr.indexOf("////")); if(lineStr.indexOf("////") == 0 ){ remarkTotal ++; System.out.println("1"); }else { logicTotal ++; System.out.println("2"); } } } private void DecodeMutilLine(Vector v){ DecodeLine(v); boolean mutilRemarkLineStart = false; for(int i =0;i<v.size() ;i++){ String line = (String)v.get(i); line.trim() ; if(line.indexOf("/*") != -1){ mutilRemarkLineStart =true; if(line.indexOf("/*") == 0){//处理第一行 remarkTotal ++; logicTotal --; }else if(line.indexOf("/*") >0){// int i = 0;/* } }else if(line.indexOf("*/") != -1){//处理最后一行 mutilRemarkLineStart = false; if(line.indexOf(";") != -1){// */ int i = 0; }else{ remarkTotal ++; logicTotal --; } } if(mutilRemarkLineStart && line.indexOf("/*") == -1 ){//国了第一行 remarkTotal ++; logicTotal --; System.out.println("3"); } } } public static void main(String[] args) { statThread statThread1 = new statThread("main.java"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -