代码:
1 | public class charCounts { |
// 测试1
2
3
4
5
6
7
8
9 public static void main(String[] args){
String path = "D:/test.txt"; //或"D://test.txt"或"D:\\test.txt"
File file = new File(path);
char des = 'a';
int count = process(file,des);
System.out.println("字符"+des+"在文中出现的次数为:"+count);
}
}