The code is same as Line count example. The additional part is the filter API call which takes a function that returns Boolean. The function has to return true for the records that need to be kept, else the records are dropped.

Let's compile the program

$mvn clean package

Once the build is successful, run the program as follows (run from where pom.xml is present)