Here you can find the source of loadToStringFromFile(String fullFileName)
public static String loadToStringFromFile(String fullFileName) throws Exception
//package com.java2s; /*//from ww w.j a v a2s .c o m * This software is distributed under the terms of the FSF * Gnu Lesser General Public License (see lgpl.txt). * * This program is distributed WITHOUT ANY WARRANTY. See the * GNU General Public License for more details. */ import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { public static String loadToStringFromFile(String fullFileName) throws Exception { List<String> lines = loadToStringListFromFile(fullFileName); if (lines == null) return (String) null; String linebreak = System.getProperty("line.separator", "\r\n"); StringBuilder sb = new StringBuilder(); Iterator<String> it = lines.iterator(); while (it.hasNext()) { sb.append(it.next()).append(linebreak); } return sb.toString(); } public static List<String> loadToStringListFromFile(String fullFileName) throws Exception { List<String> lines = new ArrayList<String>(); BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader( new FileInputStream(fullFileName), "utf-8")); while (true) { String line = br.readLine(); if (line == null) break; lines.add(line); } } catch (Exception ex) { throw ex; } finally { try { if (br != null) br.close(); } catch (Exception ex) { } } return lines; } }