Here you can find the source of readTextFile(String file)
public static String readTextFile(String file) throws Exception
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.io.BufferedReader; import java.io.FileReader; public class Main { public static String readTextFile(String file) throws Exception { String everything;/*from www .ja v a 2 s. c o m*/ try (BufferedReader br = new BufferedReader(new FileReader(file))) { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append(System.lineSeparator()); line = br.readLine(); } everything = sb.toString(); } return everything; } }