珠锋Web前端高级2022
// 统计一个文件的单词
private Map<String, Long> count(File file) {
String str;
try {
str = new String(Files.readAllBytes(file.toPath()));
} catch (IOException e) {
throw new RuntimeException(e);
}
return Stream.of(str.split("//s+")).collect(Collectors.groupingBy(word -> word, Collectors.counting()));
}}