Here you can find the source of getFileContentAsString(String path)
public static String getFileContentAsString(String path) throws Exception
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; public class Main { public static String getFileContentAsString(String path) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(path), "UTF-8")); String data = new String(); try {//from w ww .j ava 2 s . c o m String line; while ((line = br.readLine()) != null) { data = data.concat(line); } } finally { br.close(); } return data; } }