Given the code fragment: Path file = Paths.get ("courses.txt"); // line n1 Assume the courses.txt is accessible. Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?
A.
List<String> fc = Files.list(file); fc.stream().forEach (s -> System.out.println(s));
B.
Stream<String> fc = Files.readAllLines (file); fc.forEach (s - > System.out.println(s));
C.
List<String> fc = Files.readAllLines(file); fc.stream().forEach (s -> System.out.println(s));
D.
Stream<String> fc = Files.list (file); fc.forEach (s -> System.out.println(s));
In what parallel universe is this the correct answer?
static Stream<Path> list(Path dir) - Return a lazily populated Stream, the elements of which are the entries in the directory.
upvoted 2 times
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
asdfjhfgjuaDCV
4 months, 2 weeks agosteefaand
5 months, 3 weeks agoduydn
10 months, 1 week agoNoraYu
2 years, 1 month agoSvetleto13
3 years, 2 months agomaslac
3 years, 3 months agojduarte
3 years, 6 months agomaslac
3 years, 3 months ago