设计一个Java程序,输入一个文件名,打开该文本文件,并统计输出其中26个英文字母出现的次数

2024-12-22 16:08:39
推荐回答(1个)
回答1:

BufferedReader br = new BufferedReader(new InputStreamReader(new InputStream( new FileInputStream(new File("classpath:hello.txt")))));int count = 0;while(br.read!=null){String str = br.readLine();count = getCount(str);}public int getCount(String str){int count =o;int length = String.length();char c = String.charAt(i)if((c>=a&&c<=z)||(c>=A&&c<=Z)){return count ++;
}
}