Here you can find the source of readFile(String filename, boolean addEOL)
public static String readFile(String filename, boolean addEOL) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readFile(String filename, boolean addEOL) throws IOException { StringBuffer buf = new StringBuffer(); BufferedReader bufReader = null; try {// w w w . j av a 2s . c o m FileInputStream fis = new FileInputStream(filename); bufReader = new BufferedReader(new InputStreamReader(fis)); String line = ""; while ((line = bufReader.readLine()) != null) { buf.append(line); // possibly add EOL char to each line if (addEOL) buf.append('\n'); } // System.out.println(buf); } finally { if (bufReader != null) bufReader.close(); } // may be empty string if an error occurred return buf.toString(); } }