Here you can find the source of readFile(String filePath)
public static String readFile(String filePath) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String readFile(String filePath) throws IOException { BufferedReader reader = null; try {//from ww w . j a va 2 s . c o m reader = new BufferedReader(new FileReader(filePath)); StringBuilder sb = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { sb.append(line); sb.append("\n"); } return sb.toString(); } finally { if (reader != null) reader.close(); } } }