Here you can find the source of getFileContent(File file)
public static String getFileContent(File file)
//package com.java2s; //Software released under Common Public License (CPL) v1.0 import java.io.Closeable; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static String getFileContent(File file) { FileInputStream f = null; try {/*from w w w .j a v a 2 s . c o m*/ byte[] buffer = new byte[(int) file.length()]; f = new FileInputStream(file); f.read(buffer); return new String(buffer); } catch (IOException e) { throw new RuntimeException(e); } finally { closeAll(f); } } public static void closeAll(Closeable... closeables) { if (closeables != null) { for (Closeable c : closeables) { try { c.close(); } catch (Exception e) { // empty } } } } }