Here you can find the source of readFile(String filename)
public static String readFile(String filename)
//package com.java2s; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.LineNumberReader; public class Main { public static String readFile(String filename) { String return_str = ""; try {/*from w ww . j a v a 2 s .c o m*/ FileReader fr = new FileReader(filename); LineNumberReader lr = new LineNumberReader(fr, 512); while (true) { String str = lr.readLine(); if (str == null) break; return_str += str + "\n"; } lr.close(); } catch (FileNotFoundException e) { System.out.println("FILENAME:" + filename); System.out.println("File not found"); // return_str="error1!"; } catch (IOException e) { System.out.println("IO error"); // return_str="error2!"; } return return_str; } }