Here you can find the source of readFile(String f)
public static String readFile(String f) throws IOException
//package com.java2s; // copyright 2009 ActiveVideo; license: MIT; see license.txt import java.io.*; public class Main { public static String readFile(String f) throws IOException { InputStreamReader in = null; try {//w w w .jav a 2s . c om StringBuilder sb = new StringBuilder(); in = new InputStreamReader(new FileInputStream(f), "UTF-8"); int count = 0; char[] buf = new char[1024 * 10]; while ((count = in.read(buf, 0, buf.length)) > -1) sb.append(buf, 0, count); return sb.toString(); } finally { try { if (in != null) in.close(); } catch (Exception ex) { } } } }