Simplest way to read a File in a String with Java 8
Do you need a quick hack to read a text file into a Java String? With Java 8 this is a piece of cake! See this example: import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public static void main(String[] args) throws IOException { String text = new String(Files.readAllBytes(Paths.get(“myfile.txt”))); } }