Here you can find the source of readFile(String file)
public static String readFile(String file)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static String readFile(String file) { FileReader rd = null;/* ww w. j ava 2s. co m*/ try { rd = new FileReader(file); } catch (FileNotFoundException e) { e.printStackTrace(); } BufferedReader br = new BufferedReader(rd); String text = new String(); String statementString = new String(); while (text != null) { try { text = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (text != null) { statementString = statementString + "\n" + text; } } return statementString; } public static String readFile(InputStream in) { InputStreamReader rd = new InputStreamReader(in); BufferedReader br = new BufferedReader(rd); String text = new String(); String statementString = new String(); while (text != null) { try { text = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (text != null) { statementString = statementString + "\n" + text; } } return statementString; } }