Here you can find the source of readFile(String filename)
public static String readFile(String filename)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static String readFile(String filename) { File in = new File(filename); try {//from w w w . ja v a 2s . co m Reader fr = new InputStreamReader(new FileInputStream(in), "UTF-8"); char[] cbuf = new char[(int) in.length()]; try { fr.read(cbuf); String ret = String.valueOf(cbuf); fr.close(); return ret; } catch (Exception e) { e.printStackTrace(); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } return null; } }