Here you can find the source of readFile(String fileName)
private static String readFile(String fileName) throws Exception
//package com.java2s; // *** LICENSING *** import java.io.*; public class Main { private static String readFile(String fileName) throws Exception { FileInputStream reader = null; try {/*from www. ja v a2s . co m*/ reader = new FileInputStream(fileName); byte[] fileBytes = new byte[reader.available()]; reader.read(fileBytes); return new String(fileBytes); } finally { if (reader != null) reader.close(); } } }