Here you can find the source of fileToString(String file)
public static String fileToString(String file)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.File; public class Main { public static String fileToString(String file) { try {// w w w . ja va2 s. co m File fileDir = new File(file); BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream(fileDir), "UTF8")); String str, strOut = ""; while ((str = in.readLine()) != null) { str = str.replace("\uFEFF", ""); strOut += str + "\r\n"; } in.close(); return strOut; } catch (Exception e) { return ""; } } }