Here you can find the source of readFile(File file)
public static String readFile(File file) throws FileNotFoundException, IOException
//package com.java2s; // Clark & Parsia, LLC parts of this source code are available under the terms of the Affero General Public License v3. import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.Reader; public class Main { public static String readFile(File file) throws FileNotFoundException, IOException {/*w w w . j a va 2s . c om*/ return readAll(new FileReader(file)); } public static String readFile(String fileName) throws FileNotFoundException, IOException { return readAll(new FileReader(fileName)); } public static String readAll(Reader reader) throws IOException { StringBuffer buffer = new StringBuffer(); BufferedReader in = new BufferedReader(reader); int ch; while ((ch = in.read()) > -1) { buffer.append((char) ch); } in.close(); return buffer.toString(); } }