本來不想回答,翻到下面那些答復(fù)實(shí)在看不過去,就花點(diǎn)功夫整理下吧,希望對(duì)有人心能有幫助。
創(chuàng)新互聯(lián)是一家專注于做網(wǎng)站、成都網(wǎng)站建設(shè)與策劃設(shè)計(jì),馬尾網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:馬尾等地區(qū)。馬尾做網(wǎng)站價(jià)格咨詢:028-86922220
閱讀分析源代碼,一些有效的方法是:
1、閱讀源代碼的說明文檔和API文檔。
2、如果源代碼有用法示例或向?qū)?,先閱讀這個(gè)。
3、了解整個(gè)項(xiàng)目的模塊結(jié)構(gòu),可以按模塊進(jìn)行閱讀。
4、隨時(shí)使用查找功能(或超鏈接)閱讀關(guān)聯(lián)類或關(guān)聯(lián)方法。
5、對(duì)于有疑問的地方,不妨寫幾行單元測試。
6、由淺入深,由易到難,多閱讀優(yōu)秀的開源項(xiàng)目,代碼閱讀水平會(huì)突飛猛進(jìn)。
package?test2;
import?java.io.BufferedReader;
import?java.io.File;
import?java.io.FileInputStream;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.InputStream;
import?java.io.InputStreamReader;
import?java.util.HashMap;
import?java.util.Map;
import?java.util.Set;
public?class?JavaCodeAnalyzer?{
public?static?void?analyze(File?file)?throws?IOException{
//FileOutputStream?fos?=?new?FileOutputStream("F;"+File.separator+"result.txt");
if(!(file.getName().endsWith(".txt")||file.getName().endsWith(".java"))){
System.out.println("輸入的分析文件格式不對(duì)!");
}
InputStream?is=?new?FileInputStream(file);
BufferedReader?br=?new?BufferedReader(new?InputStreamReader(is));
String?temp;
int?count=0;
int?countSpace=0;
int?countCode=0;
int?countDesc=0;
MapString,?Integer?map?=?getKeyWords();
while((temp=br.readLine())!=null){
countKeys(temp,?map);
count++;
if(temp.trim().equals("")){
countSpace++;
}else?if(temp.trim().startsWith("/*")||temp.trim().startsWith("http://")){
countDesc++;
}else{
countCode++;
}
}
System.out.printf("代碼行數(shù):"+countCode+"占總行數(shù)的%4.2f\n",(double)countCode/count);
System.out.printf("空行數(shù):"+countSpace+"占總行數(shù)的%4.2f\n",(double)countSpace/count);
System.out.printf("注釋行數(shù):"+countDesc+"占總行數(shù)的%4.2f\n",(double)countDesc/count);
System.out.println("總行數(shù):"+count);
System.out.println("出現(xiàn)最多的5個(gè)關(guān)鍵字是:");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
}
public?static?void?main(String[]?args)?{
getKeyWords();
File?file?=?new?File("F://Test.java");
try?{
analyze(file);
}?catch?(IOException?e)?{
//?TODO?自動(dòng)生成?catch?塊
e.printStackTrace();
}
}
public?static?MapString,Integer?getKeyWords(){
MapString,Integer?map?=?new?HashMapString,?Integer();
String[]keywords?=?{"abstract","assert","boolean","break","byte","case","catch","char","class","continue","default","do","double","else","enum","extends","final","finally","float","for","if","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","return","????strictfp","short","static","super","????switch","synchronized","this","throw","throws","transient","try","void","volatile","while","goto","const"};
for(String?s:keywords){
map.put(s,?0);
}
return?map;
}
public?static?void?countKeys(String?s,MapString,Integer?map){
SetString?keys?=?map.keySet();
for(String?ss:keys){
if(s.indexOf(ss)!=-1){
map.put(ss,?map.get(ss)+1);
}
}
}
}
上班沒啥時(shí)間了,還有點(diǎn)沒寫完,你在想想。
先不說公司的保密協(xié)議
一個(gè)項(xiàng)目的代碼能在這里全貼出來,還給你講解的清楚?
、不過整個(gè)取款機(jī)流程是很簡單的,就是用戶進(jìn)行不同的操作,
java 調(diào)用 JNI驅(qū)動(dòng)硬件執(zhí)行相應(yīng)的操作,關(guān)鍵就是組織各種類型的報(bào)文,
通過DTU發(fā)送到銀聯(lián)那邊,比如說支付報(bào)文,沖正報(bào)文,日結(jié)報(bào)文……
這些報(bào)文的組織一般java 也只管傳入JNI 中C++組裝好以后再調(diào)用 DTU驅(qū)動(dòng)發(fā)送
java 這一塊就是處理一些邏輯或者頁面流轉(zhuǎn)之類的、
代碼是不可能貼的,保密協(xié)議還是有一定的約束力的
MyView myView = new MyView();
myView.anyView = this;
this.remove(this.xxPanel);
this.add(myView.getPanel());
this.repaint();