Here you can find the source of getFileContent(String filePath)
public static String getFileContent(String filePath)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static String getFileContent(String filePath) { File file = new File(filePath); if (!file.exists() || !file.isFile()) { return null; }/*from ww w . j a v a 2s . c om*/ StringBuffer content = new StringBuffer(); try { char[] temp = new char[1024]; FileInputStream fileInputStream = new FileInputStream(file); InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); while (inputStreamReader.read(temp) != -1) { content.append(new String(temp)); temp = new char[1024]; } fileInputStream.close(); inputStreamReader.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return content.toString(); } }