Here you can find the source of readFile(String path)
public static String readFile(String path) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; public class Main { public static String readFile(String path) throws Exception { File file = new File(path); FileReader fileReader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(fileReader); StringBuffer stringBuffer = new StringBuffer(); String str;/*from ww w.j a va2s .com*/ str = bufferedReader.readLine(); while (str != null) { stringBuffer.append(str); stringBuffer.append("\r\n"); str = bufferedReader.readLine(); } bufferedReader.close(); fileReader.close(); return stringBuffer.toString(); } }