1.

How to read entire file in one line using java 8?(a) Files.readAllLines()(b) Files.read()(c) Files.readFile()(d) Files.lines()This question was addressed to me by my school teacher while I was bunking the class.This intriguing question originated from File and Directory in chapter Autoboxing & Miscellaneous of Java

Answer»

Correct ANSWER is (a) Files.readAllLines()

The best explanation: Java 8 provides Files.readAllLines() which allows us to READ entire file in ONE task. We do not NEED to worry about READERS and writers.



Discussion

No Comment Found

Related InterviewSolutions