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("输入的分析文件格式不对!")
}
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
Map<String, 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("//")){
countDesc++
}else{
countCode++
}
}
System.out.printf("代码行数:"+countCode+"占总行数的%4.2f\n",(double)countCode/count)
System.out.printf("空行数:"+countSpace+"占总行数的%4.2f\n",(double)countSpace/count)
System.out.printf("注释行数:"+countDesc+"占总行数的%4.2f\n",(double)countDesc/count)
System.out.println("总行数:"+count)
System.out.println("出现最多的5个关键字是:")
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 自动生成 catch 块
e.printStackTrace()
}
}
public static Map<String,Integer> getKeyWords(){
Map<String,Integer> map = new HashMap<String, 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,Map<String,Integer> map){
Set<String> keys = map.keySet()
for(String ss:keys){
if(s.indexOf(ss)!=-1){
map.put(ss, map.get(ss)+1)
}
}
}
}
上班没啥时间了,还有点没写完,你在想想。
先不说公司的保密协议一个项目的代码能在这里全贴出来,还给你讲解的清楚?
、不过整个取款机流程是很简单的,就是用户进行不同的操作,
java 调用 JNI驱动硬件执行相应的操作,关键就是组织各种类型的报文,
通过DTU发送到银联那边,比如说支付报文,冲正报文,日结报文……
这些报文的组织一般java 也只管传入JNI 中C++组装好以后再调用 DTU驱动发送
java 这一块就是处理一些逻辑或者页面流转之类的、
代码是不可能贴的,保密协议还是有一定的约束力的
MyView myView = new MyView()
myView.anyView = this
this.remove(this.xxPanel)
this.add(myView.getPanel())
this.repaint()
‘’占一个位,你想一下,如果值是1,那么你怎么输入汉字Character类的使用方法
Character:字符类型
1、属性。
static int MIN_RADIX :返回最小基数。