Here you can find the source of readFile(String filename)
public static String readFile(String filename) throws IOException
//package com.java2s; //License from project: LGPL import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(String filename) throws IOException { String content = null;/*from w w w. j a v a 2 s.c o m*/ File file = new File(filename); 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) { reader.close(); } } return content; } }