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.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.Reader; public class Main { public static String readFile(String filename) throws IOException { return readFile(new File(filename)); }//from w ww . j av a 2s .c o m public static String readFile(File file) throws IOException { Reader inputScript = getFileReader(file); BufferedReader br = new BufferedReader(inputScript); String line; StringBuffer sb = new StringBuffer(); while ((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); return sb.toString(); } public static Reader getFileReader(String filename) throws FileNotFoundException { return getFileReader(new File(filename)); } public static Reader getFileReader(File file) throws FileNotFoundException { return new FileReader(file); } }