Here you can find the source of readFileByCharAsString(String path, String encode)
public static String readFileByCharAsString(String path, String encode) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readFileByCharAsString(String path, String encode) throws IOException { InputStream in = new FileInputStream(path); BufferedReader reader = new BufferedReader(new InputStreamReader(in, encode)); StringBuffer contentbuffer = new StringBuffer(); char[] temp = new char[1024]; int size = 0; while ((size = reader.read(temp, 0, 1024)) != -1) { String tempstr = new String(temp, 0, size); contentbuffer.append(tempstr); }/* w ww . j a va 2s .com*/ String content = contentbuffer.toString(); reader.close(); return content; } }