Skip to content
Sharp

I/O · interview question

Which java.nio.file.Files method reads all lines of a small text file into a List<String>? (method name)

Fill in the blankMedium
Answer and explanation

Correct answer

readAllLines or Files.readAllLines or readAllLines()

Why

Files.readAllLines(path) loads everything into memory (UTF-8 by default). For big files, stream with Files.lines(path) inside try-with-resources.

Test yourself on I/O

A free test with instant, explained results. No account needed.

Start free test
All I/O questions →