Here you can find the source of readFile(String filename)
public static String readFile(String filename) throws IOException
//package com.java2s; /*************************************************************************** * Copyright (C) 2004, Patrick Charles and Jonas Lehmann * * Distributed under the Mozilla Public License * * http://www.mozilla.org/NPL/MPL-1.1.txt * ***************************************************************************/ import java.io.FileReader; import java.io.IOException; import java.io.File; import java.io.BufferedReader; public class Main { public static String readFile(String filename) throws IOException { String readString = ""; String tmp;//from www.j av a2 s .com File f = new File(filename); char[] readIn = new char[(new Long(f.length())).intValue()]; BufferedReader in = new BufferedReader(new FileReader(f)); in.read(readIn); readString = new String(readIn); in.close(); return readString; } }