Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java words from file

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)
 
PREVIOUS NEXT
Tagged: #java #words #file
ADD COMMENT
Topic
Name
5+2 =