Here you can find the source of readFile(String fileName)
public static StringBuilder readFile(String fileName) 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 StringBuilder readFile(String fileName) throws FileNotFoundException, IOException { FileReader fr = new FileReader(fileName); BufferedReader br = new BufferedReader(fr); String s;// w ww . j a v a 2 s .c o m StringBuilder sb = new StringBuilder(); while ((s = br.readLine()) != null) { sb.append(s + "\r\n"); } fr.close(); br.close(); return sb; } }