Here you can find the source of readAll(String filePath)
public static String readAll(String filePath)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static String readAll(String filePath) { try {/* w ww .ja v a 2s .c o m*/ FileReader fr = new FileReader(filePath); BufferedReader br = new BufferedReader(fr); String res = ""; String buf; while ((buf = br.readLine()) != null) { res += buf; } br.close(); fr.close(); return res; } catch (IOException e) { e.printStackTrace(); } return null; } public static String readAll(String path, String charset) { try { File file = new File(path); if (!file.exists()) { return null; } FileInputStream inputStream = new FileInputStream(file); byte[] length = new byte[inputStream.available()]; inputStream.read(length); inputStream.close(); return new String(length, charset); } catch (Exception e) { e.printStackTrace(); } return null; } }