Here you can find the source of fileToString(File f)
public static String fileToString(File f)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String fileToString(File f) { try {/* w w w .j a v a2 s . com*/ FileReader fr = new FileReader(f); char[] tmp = new char[(int) f.length()]; char c; int j = 0; for (int i = fr.read(); i != -1; i = fr.read()) { c = (char) i; tmp[j] = c; j++; } fr.close(); String ret = new String(tmp); return ret; } catch (Exception e) { System.err.println("failed to read file: \"" + f.getName() + "\"!"); return ""; } } }