Here you can find the source of FileToString(String file_name)
public static String FileToString(String file_name) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String FileToString(String file_name) throws Exception { FileInputStream fis = new FileInputStream(file_name); return InputStreamToString(fis); }/* w w w. j a va 2 s.co m*/ public static String InputStreamToString(InputStream input_stream) throws Exception { StringBuilder sb = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(input_stream, "UTF-8")); String sBuffer = br.readLine(); while (sBuffer != null) { sb.append(sBuffer); sb.append(System.lineSeparator()); sBuffer = br.readLine(); } return sb.toString(); } }