Here you can find the source of loadText(File f)
public static String loadText(File f) throws IOException
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; public class Main { public static String loadText(File f) throws IOException { return loadReader(new InputStreamReader(new FileInputStream(f))); }//from ww w. j a va 2 s.c o m public static String loadReader(Reader stream) throws IOException { BufferedReader r = null; StringBuilder text = new StringBuilder(); try { r = new BufferedReader(stream); String line = null; while ((line = r.readLine()) != null) { text.append(line); text.append(System.getProperty("line.separator")); } } finally { if (r != null) { r.close(); } } return text.toString(); } }