Question:
Assuming the current directory is /home and the directories and files referenced by the program exist, what is true about the following code snippet? (Choose all that apply.)
Path path1 = Paths.get("/lemur/habitat/./party.txt");
Path path2 = path1.subpath(1,4).toAbsolutePath();
System.out.println(Files.lines(path2)
.flatMap(p -> Stream.of(p.split(",")))
.filter(s -> s.trim().length()>0)
.allMatch(s -> s.length()>3));
A. It will access the file /lemur/habitat/party.txt.
B. It will access the file /habitat/party.txt.
C. It will access the file /home/habitat/party.txt.
D. If the
String value ,,, is contained within the file, it will definitely print false.
E. If the String value ,hat, is contained within the file, it will definitely print false.
F. It will always print false.
G. The code does not compile
Answer: B, E
-----------
The problem is answer should be C, E. Even description inside answer matches C option. The description says:
"The value path1.subpath(1,4) returns habitat/./party.txt, which we join to the current directory /home with the toAbsolutePath() method in order to see that we are accessing the file /home/habitat/party.txt"