Here you can find the source of readFileAsString(String fpath)
public static String readFileAsString(String fpath) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFileAsString(String fpath) throws IOException { final BufferedReader brdr = new BufferedReader(new FileReader(fpath)); final StringBuilder sr = new StringBuilder(fpath.length()); String s = null;/*from w w w . j a v a 2 s .c o m*/ try { while ((s = brdr.readLine()) != null) { sr.append(s).append('\n'); } } finally { brdr.close(); } return sr.toString(); } }