Here you can find the source of readFile(File file)
public static String readFile(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(File file) { String content = null;// ww w.jav a 2s . c o m FileReader reader = null; try { reader = new FileReader(file); char[] chars = new char[(int) file.length()]; reader.read(chars); content = new String(chars); reader.close(); } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } } } return content; } }