I have the following line stream that I read from a file
1 2 4.5
1 6 3 5.5 5.3 6
1 7.2 5 7
How can I collect these lines in a single list of list considering only the Integers? (Notice that within each line the numbers are separated by one or more white spaces)
This is what I tried, but this give me one single list of all integer elements.
list = reader.lines()
.map(m -> m.split("\\n"))
.flatMap(Arrays::stream)
.map(m -> m.split("\\s+"))
.flatMap(Arrays::stream)
.filter(f -> !f.contains("."))
.map(Integer::parseInt)
.collect(Collectors.toList());