tokuhirom
4/20/2015 - 3:10 AM

https://www.ntts.co.jp/products/grails/feature.html#navi01

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Hoge {
	public static void main(String[] args) throws IOException {
		Files.readAllLines(Paths.get(args[0])).stream()
			.flatMap(line -> Arrays.stream(line.split("\\W+")))
			.filter(word -> !word.isEmpty())
			.collect(Collectors.groupingBy(r -> r, Collectors.counting())).entrySet()
			.stream().sorted((a, b) -> (int)(a.getValue() - b.getValue()))
			.forEach(it -> System.out.println(it.getValue() + ":"
				+ it.getKey()));
	}
}