Here you can find the source of getContent(String file, String encodType)
public static String getContent(String file, String encodType) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String getContent(String file, String encodType) throws IOException { // "xx\r\n" read -> "xx" StringBuffer content = new StringBuffer(); FileInputStream fis = new FileInputStream(file); DataInputStream dis = new DataInputStream(fis); BufferedReader br = new BufferedReader(new InputStreamReader(dis, encodType));/*from w w w . j a v a 2 s . c o m*/ String line = null; if ((line = br.readLine()) != null) { content.append(line); } while ((line = br.readLine()) != null) { content.append("\r\n" + line); } br.close(); dis.close(); fis.close(); return content.toString(); } }