Here you can find the source of readfile(File path)
public static String readfile(File path)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String readfile(String path) { String resp = ""; File f;//from w w w. j av a2 s . c o m FileInputStream inp; try { f = new File(path); inp = new FileInputStream(f); byte[] bf = new byte[(int) f.length()]; inp.read(bf); resp = new String(bf, "UTF-8"); inp.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return resp; } public static String readfile(File path) { String resp = ""; FileInputStream inp; try { inp = new FileInputStream(path); byte[] bf = new byte[(int) path.length()]; inp.read(bf); resp = new String(bf, "UTF-8"); inp.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return resp; } }