Here you can find the source of fileToString(final File f, final Charset c)
public static String fileToString(final File f, final Charset c) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.nio.charset.Charset; public class Main { public static String fileToString(final File f, final Charset c) throws IOException { return new String(fileToByteArray(f), c); }// ww w .ja va 2s . c om public static byte[] fileToByteArray(final File f) throws IOException { final FileInputStream is = new FileInputStream(f); final byte[] ret = new byte[(int) f.length()]; int p = 0; while (p < ret.length) p += is.read(ret, p, ret.length - p); is.close(); return ret; } }