Here you can find the source of readFileData(File file)
public static String readFileData(File file) throws Exception
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readFileData(File file) throws Exception { StringBuilder sb = new StringBuilder(); FileInputStream in = null; BufferedReader br = null; try {/* ww w . j av a 2 s. c o m*/ in = new FileInputStream(file); br = new BufferedReader(new InputStreamReader(in)); String data = null; while ((data = br.readLine()) != null) { sb.append(data); } } catch (Exception e) { throw e; } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } return sb.toString(); } }