Here you can find the source of readFileAll(File file, String charsetName)
public static String readFileAll(File file, String charsetName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readFileAll(File file, String charsetName) throws IOException { return readInputStreamAll(new FileInputStream(file), charsetName); }/*from ww w . ja v a2 s . com*/ public static String readFileAll(File file) throws IOException { return readFileAll(file, "UTF-8"); } public static String readInputStreamAll(InputStream inputStream, String charsetName) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, charsetName)); StringBuilder sb = new StringBuilder(); int c; while ((c = reader.read()) != -1) { sb.append((char) c); } reader.close(); return sb.toString(); } public static String readInputStreamAll(InputStream inputStream) throws IOException { return readInputStreamAll(inputStream, "UTF-8"); } }