Here you can find the source of readFile(String path)
public static String readFile(String path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readFile(String path) throws IOException { StringBuilder sb = new StringBuilder(); BufferedReader br = null; br = new BufferedReader(new InputStreamReader(new FileInputStream(path), "UTF-8")); String line;/*from w w w . jav a2s . c om*/ if ((line = br.readLine()) != null) sb.append(line); while ((line = br.readLine()) != null) { sb.append(System.getProperty("line.separator")); sb.append(line); } br.close(); return sb.toString(); } }