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 { StringBuilder sb = new StringBuilder(); final BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName)); String line = bufferedReader.readLine(); while (line != null) { sb.append(line).append("\n"); line = bufferedReader.readLine(); }/*from w w w . j a v a 2s .co m*/ return sb.toString(); } }