Here you can find the source of loadTextFile(String fileName)
public static String loadTextFile(String fileName) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileReader; public class Main { public static String loadTextFile(String fileName) throws Exception { BufferedReader br = new BufferedReader(new FileReader(fileName)); String text = ""; try {/*from w w w . jav a 2 s.c o m*/ StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append("\n"); line = br.readLine(); } text = sb.toString(); } finally { br.close(); } return text; } }