统计一个文件test.txt中各个字母出现次数: A(8),B(16),C(10)…,a(12),b(10),c(3)…,括号内代表字符出现次数.
public class Demo01 {
public static void main(String[] args) {
System.out.println(countLetterChars());
}
//编写一个实现方法
private static String countLetterChars() {
// 创建一个TreeMap集合
TreeMap<Character, Integer> tm = new TreeMap<>();
StringBuilder sb = new StringBuilder();
// 声明字缓冲输入流
try (