巧妙使用使用数组快速统计字符出现次数
public static void main(String[] args) throws IOException{int[] cs = new int[Character.MAX_VALUE];Reader reader = new FileReader(new File("F:/log.txt"));int index;while((index = reader.read()) != -1){cs[index]++;}for(int i=0;i<cs.length;i++){if(cs[i]!=0)System.out.println((char)i+"出现次数:"+cs[i]);}}