Here you can find the source of readFile(String fileName)
public static String readFile(String fileName)
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class Main { private final static String NEW_LINE = System.getProperty("line.separator"); public static String readFile(String fileName) { String retStr = ""; File f = new File(fileName); try {//from ww w.ja v a2 s.c o m BufferedReader br = new BufferedReader(new FileReader(f)); StringBuffer buff = new StringBuffer(); String line = br.readLine(); while (line != null) { buff.append(line + NEW_LINE); line = br.readLine(); } retStr = buff.toString(); br.close(); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } return retStr; } }