Here you can find the source of readFile(File file)
public static String readFile(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String readFile(File file) throws IOException { FileInputStream fstream = null; try {//from w ww . j a v a 2s.c o m fstream = new FileInputStream(file); byte[] bytes = new byte[(int) file.length()]; fstream.read(bytes); fstream.close(); return new String(bytes); } catch (Exception e) { throw new IOException(e); } finally { quiteClose(fstream); } } public static void quiteClose(Closeable stream) { try { if (stream != null) { stream.close(); } } catch (IOException e) { /* Ignore */ } } }