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.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.Reader; public class Main { public static String readFile(String filename) throws IOException { return readAll(new FileReader(filename)); }/* www .j ava 2 s .c om*/ public static String readAll(Reader reader) throws IOException { BufferedReader bufferedReader = new BufferedReader(reader); StringBuilder builder = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { builder.append(line).append("\n"); } bufferedReader.close(); return builder.toString(); } }