Here you can find the source of readFile(File f)
public static String readFile(File f) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readFile(File f) throws IOException { return read(new FileInputStream(f)); }//from ww w. j a v a 2s . c o m public static String read(InputStream in) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(in)); StringBuilder b = new StringBuilder(); String line = null; while ((line = r.readLine()) != null) { b.append(line); b.append('\n'); } return b.toString(); } }