Here you can find the source of readFile(String filePath)
public static String readFile(String filePath)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(String filePath) { try {/*from w w w. j av a2 s.c o m*/ BufferedReader br = new BufferedReader(new FileReader(new File(filePath))); StringBuffer sb = new StringBuffer(); String line = null; while ((line = br.readLine()) != null) { sb.append(line + "\n"); } return sb.toString(); } catch (IOException e) { e.printStackTrace(); return null; } } }