Hi everybody!
I am new here, I am studying the OCP 8 certificate and I have a problem with this code snippet: ( it is from the book OCP8 Boyarsky-Selikoff, chapter 9 question 16)
Path path = Paths.get("/squid/food-schedule.csv");
Files.lines(path)
.flatMap(p -> Stream.of(p.split(",")))
.map(s -> s.toUpperCase())
.forEach(System.out::println);
The correct answer following the book is:
F. If it prints anything, it will not include commas.
and the explanation says that "The result is printed with one entry on a single line, but all original line breaks and commas from the file are removed"
I spent a lot of hours on internet trying to get a little bit more deep explanation about this piece of code, but I didn´t see anything
I don´t know why is not keeping the original line breaks and commas, why are removed? and why is printed in a single line if the code split the file into lines....
I don´t understand I have been searching on google any answer and I am not able to finde the explanation to this...
I checked Files.lines method as well as flatMap and map methods, but I don´t get the answer.
Please, anybody could help me?
Thank you very much in advance