Here you can find the source of readFile(String filename)
public static String readFile(String filename)
//package com.java2s; import java.io.*; public class Main { public static String readFile(String filename) { File in = new File(filename); try {//from w w w . j av a2 s.c o m Reader fr = new InputStreamReader(new FileInputStream(in), "UTF-8"); char[] cbuf = new char[(int) in.length()]; try { fr.read(cbuf); return String.valueOf(cbuf); } catch (Exception e) { e.printStackTrace(); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } return null; } }