Assuming /data/employee.csv exists as a regular non-empty file that a program has access to read, what is correct about the following code snippet? (Choose all that apply.).
Path path = Paths.get("/data/employee.csv"); Files.lines(path) // r1 .flatMap(p -> Stream.of(p.split(","))) // r2 .map(s -> s.toUpperCase()) // r3 .forEach(System.out::println);
F.
The code compiles without issue, so B, C, and D are incorrect.
The code snippet breaks a file into lines and then further separates the lines by commas using the flatMap()
method.
The result is printed with one entry on a single line, but all original line breaks and commas from the file are removed; therefore F is correct.
Since we are told that the file is non-empty and regular, and the program has access to read it, A and E are incorrect.