Here you can find the source of readFile(String fileName)
public static String readFile(String fileName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readFile(String fileName) throws IOException { FileInputStream fis = new FileInputStream(fileName); BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8")); StringBuilder sb = new StringBuilder(); while (in.ready()) { String line = in.readLine(); sb.append(line).append('\n'); }/*from ww w .j ava 2s . c o m*/ in.close(); fis.close(); return sb.toString(); } }