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.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.Scanner; public class Main { /**/*from w w w .jav a2s . c o m*/ * Reads the file with the specified path as a String. */ public static String readFile(String filePath) throws IOException { BufferedReader br = new BufferedReader(new FileReader(filePath)); Scanner sc = new Scanner(br); try { return sc.useDelimiter("\\Z").next(); } finally { sc.close(); br.close(); } } }