Here you can find the source of readFile(File f)
public static String readFile(File f) throws IOException
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.io.*; public class Main { public static String readFile(File f) throws IOException { try (FileInputStream fis = new FileInputStream(f)) { byte[] data = new byte[(int) f.length()]; fis.read(data);//from w ww . ja va 2 s .co m return new String(data, "UTF-8"); } } }