国培教育网:急求JAVA小程序代码(20分重赏)

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 03:01:08
我是在校学生,期末课程设计,老师要求用JAVA语言编个小程序,具体要求如下:1.该程序执行时可以传递一个参数,打开该参数所描述的文本(文本文件)2.输出文件的内容 3.输出文件里出现过的字符,及每个字符出现的频率 希望哪为能人能尽快帮帮我,给我个符合上面要求的代码,谢谢了!20分重赏!骗人的就不要来打扰了 !谢谢!

try{
final int EOF = -1;
HashTable h = new HashTable();
Reader r = new FileReader(new File(args[0]));
int c = r.read();
while (c != EOF){
System.out.print((char)c); // 未作缓冲
Character key = new Character((char)c);
Object count = h.get(key);
if (count == null){count = new Integer(1);}
else {count = new Integer(((Integer)count).intValue + 1);}
h.put(key, count);
c = r.read();
}
}catch{...}