Here you can find the source of readAllFromFile(File f)
public static String readAllFromFile(File f) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static String readAllFromFile(File f) throws IOException { FileInputStream fis = new FileInputStream(f); byte[] buf = new byte[2048]; int read; ByteArrayOutputStream bos = new ByteArrayOutputStream(); while ((read = fis.read(buf)) != -1) { bos.write(buf, 0, read);//from ww w. j ava 2 s . c o m } fis.close(); return bos.toString(); } }