November 2017
Beginner to intermediate
290 pages
7h 34m
English
In order to count the words, we have to get the words. For simplicity, we will just hand-craft a regular expression for splitting, and not even take into account any text file formatting:
FlatMapElements
.into(TypeDescriptors.strings())
.via((String word) -> Arrays.asList(word.split("[^\\p{L}]+")))
Here, FlatMapElements accepts a function that takes one input and results in possibly many outputs. It is identical to flatMap you may be familiar with from functional programming.
Read now
Unlock full access