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 = readAllLines(file); fc.stream().forEach (s - > System.out.println(s));
D.
Stream<String> fc = Files.lines (file); fc.forEach (s - > System.out.println(s));
Yes thats correct.We usually use readAllLines() for large files and lines() for small files.
upvoted 1 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.
pul26
Highly Voted 3 years, 7 months agoasdfjhfgjuaDCV
Most Recent 4 months, 4 weeks agosteefaand
5 months, 3 weeks agoWilsonKKerll
2 years, 5 months agoiamajavacompiler
3 years, 3 months agoshivkumarx
4 months, 3 weeks agoSvetleto13
3 years, 1 month ago