java words из файла

Files.lines(Paths.get("my_file.txt"))
  
  			// exclude "empty" lines
            .filter(line -> line.length() > 0)
  
  			// map every word           
  			.map(line -> Arrays.asList(line.split("\s")))
  
            // flatten 
  			.flatMap(List::stream)
  
  			// optional for non duplicates
  			// .distinct()
  
            // optional for sorted
  			// .sorted(Comparator.reverseOrder())
  
  			// optional group by length
  			// .collect(Collectors.groupingBy((String::length)
Inexpensive Ibex