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