Here you can find the source of readFile(String path)
public static String readFile(String path)
//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 path) { StringBuilder text = new StringBuilder(); BufferedReader reader = null; try {//from ww w. ja v a 2 s. c o m reader = new BufferedReader(new FileReader(path)); String line; while ((line = reader.readLine()) != null) text.append(line).append("\n"); } catch (Exception ex) { throw new RuntimeException(ex.getMessage()); } try { reader.close(); } catch (IOException ex) { throw new RuntimeException(ex.getMessage()); } return text.toString(); } }