Here you can find the source of readFile(String path)
public static String readFile(String path)
//package com.java2s; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; public class Main { public static String readFile(String path) { StringBuffer str = new StringBuffer(""); try {/*from ww w .ja v a2s. c om*/ InputStreamReader ir = new InputStreamReader( new FileInputStream(path), "UTF8"); BufferedReader br = new BufferedReader(ir); String data = br.readLine(); while (data != null) { str.append(data); data = br.readLine(); } br.close(); ir.close(); } catch (Exception e) { e.printStackTrace(); } return str.toString(); } }