Here you can find the source of readFile(String filePath)
public static String readFile(String filePath) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readFile(String filePath) throws IOException { String result = new String(); FileInputStream fstream = new FileInputStream(filePath); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine;//from w w w. j av a 2s . c o m while ((strLine = br.readLine()) != null) { result += strLine + "\n"; } in.close(); return result; } }