Here you can find the source of readFile(final String fileName)
public static String readFile(final String fileName) throws IOException
//package com.java2s; // The MIT License import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.Reader; public class Main { public static String readFile(final String fileName) throws IOException { return readAll(new FileReader(fileName)); }//from w w w. ja v a 2 s . com public static String readAll(final Reader reader) throws IOException { final StringBuffer buffer = new StringBuffer(); final BufferedReader in = new BufferedReader(reader); int ch; while ((ch = in.read()) > -1) { buffer.append((char) ch); } in.close(); return buffer.toString(); } }