Here you can find the source of readFile(File file)
public static String readFile(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(File file) throws IOException { FileReader a = null;/* ww w .j a va 2s .c o m*/ char[] d = null; try { a = new FileReader(file); int b; int c = 0; char[] e = null; b = a.read(); while (b >= 0) { e = new char[c + 1]; if (d != null) { System.arraycopy(d, 0, e, 0, d.length); } else { d = new char[1]; } e[c] = (char) b; d = e.clone(); c++; b = a.read(); } } finally { if (a != null) { a.close(); } } if (d != null) { return String.copyValueOf(d); } else { return ""; } } }