Here you can find the source of readFile(File file)
public static String readFile(File file) throws IOException
//package com.java2s; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.Reader; import java.io.StringWriter; import java.io.Writer; public class Main { public static String readFile(File file) throws IOException { Reader in = new FileReader(file); StringWriter out = new StringWriter(); copy(in, out);//from ww w. j av a 2s .c o m return out.toString(); } public static void copy(Reader in, Writer out) throws IOException { int c = -1; while ((c = in.read()) != -1) { out.write(c); } } }