Here you can find the source of readFile(String path)
public static String readFile(String path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String readFile(String path) throws IOException { StringBuilder sb = new StringBuilder(); String sCurrentLine = ""; try (BufferedReader br = new BufferedReader(new FileReader(path))) { while ((sCurrentLine = br.readLine()) != null) { sb.append(sCurrentLine); }// ww w. j av a2 s . co m } return sb.toString(); } }