Here you can find the source of readTextFile(String path)
static public String readTextFile(String path) throws IOException
//package com.java2s; // LICENSE: This file is distributed under the BSD license. import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { static public String readTextFile(String path) throws IOException { String newLine = System.getProperty("line.separator"); StringBuffer sb = new StringBuffer(); BufferedReader input = new BufferedReader(new FileReader(path)); String line;/*from w w w . j av a 2 s. c o m*/ while (null != (line = input.readLine())) { if (sb.length() > 0) sb.append(newLine); sb.append(line); } return sb.toString(); } }