Here you can find the source of readTextFile(String sFileName, String sEncode)
private static String readTextFile(String sFileName, String sEncode)
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; public class Main { private static String readTextFile(String sFileName, String sEncode) { StringBuffer sbStr = new StringBuffer(); try {/*from ww w . j ava2 s . c o m*/ File ff = new File(sFileName); InputStreamReader read = new InputStreamReader( new FileInputStream(ff), sEncode); BufferedReader ins = new BufferedReader(read); String dataLine = ""; while (null != (dataLine = ins.readLine())) { sbStr.append(dataLine); // sbStr.append("/r/n"); } ins.close(); } catch (Exception e) { e.printStackTrace(); } return sbStr.toString(); } }