Here you can find the source of readFile(String filename)
public static String readFile(String filename)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(String filename) { StringBuilder s = new StringBuilder(); BufferedReader in = null; try {// ww w . j a va 2 s . com in = new BufferedReader(new FileReader("infilename")); String str; while ((str = in.readLine()) != null) { s.append(str).append("\n"); // TODO RBE make this newline OS safe. } } catch (IOException e) { e.printStackTrace(); } finally { try { in.close(); } catch (IOException e) { } } return s.toString(); } }