Here you can find the source of readAll(String path)
public static String readAll(String path) throws FileNotFoundException, IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class Main { public static String readAll(String path) throws FileNotFoundException, IOException { BufferedReader br = new BufferedReader(new FileReader(path)); StringBuilder sb = new StringBuilder(); try {// w w w .ja v a 2 s . c o m String line = br.readLine(); while (line != null) { sb.append(line); sb.append(System.lineSeparator()); line = br.readLine(); } } finally { br.close(); } return sb.toString(); } }