Here you can find the source of fileToStr(String strInput)
public static String fileToStr(String strInput) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String fileToStr(String strInput) throws IOException { // It is implicit that the input is a file so... File f = new File(strInput); // Ensure we have the capacity to prevent constant reallocation StringBuilder sb = new StringBuilder(new Long(f.length()).intValue()); FileInputStream fIn = new FileInputStream(strInput); BufferedReader br = new BufferedReader(new InputStreamReader(fIn)); String line = null;//from ww w . ja v a2s . co m while ((line = br.readLine()) != null) { sb.append(line); sb.append("\n"); } br.close(); return sb.toString(); } }