Read a File

Java Read File to String: readString() and 7 More Ways

Learn to read a file to String in Java with Files.readString() (Java 11), Files.readAllBytes(), Files.readAllLines() and lines(), BufferedReader, Scanner and FileInputStream, plus how to read from the classpath, avoid charset and line separator mistakes and stream large files.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.