Here you can find the source of readFile(File f)
public static String readFile(File f) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; public class Main { public static String readFile(File f) throws Exception { String res = ""; BufferedReader br = null; br = new BufferedReader(new FileReader(f)); String line = null;//w w w . ja va2 s . co m while ((line = br.readLine()) != null) { res += line; } try { br.close(); } catch (Exception e) { } return res; } }