Here you can find the source of getFileContent(String path, String encoding)
public static String getFileContent(String path, String encoding)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String getFileContent(String path, String encoding) { StringBuffer sb = new StringBuffer(); BufferedReader r = null;//from www .j a v a 2s . com try { r = new BufferedReader(new InputStreamReader( new FileInputStream(path), encoding)); String line; while ((line = r.readLine()) != null) { sb.append(line); sb.append("\n"); } } catch (FileNotFoundException e) { System.out.println("warning: file not found: " + path); } catch (Exception e) { e.printStackTrace(); } finally { try { if (r != null) r.close(); } catch (Exception e) { } } return sb.toString(); } }