Here you can find the source of readFile(String fileName)
public static String readFile(String fileName) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(String fileName) throws IOException { BufferedReader br = new BufferedReader(new FileReader(fileName)); StringBuilder everything = new StringBuilder(); String line = ""; try {/*w ww . ja v a 2 s .c o m*/ line = br.readLine(); while (line != null) { everything.append(line + "\n"); line = br.readLine(); } } catch (Exception ex) { System.out.println("Line Error: " + line); ex.printStackTrace(); } finally { br.close(); } return everything.toString(); } }