Here you can find the source of getFileContent(File file, String charsetName)
public static String getFileContent(File file, String charsetName) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static String getFileContent(File file, String charsetName) throws IOException { if (file == null) return null; BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetName)); String content;/*from w w w .ja va2 s .com*/ StringBuilder sb = new StringBuilder(); while (true) { content = bf.readLine(); if (content == null) { break; } sb.append(content.trim()); } bf.close(); return sb.toString(); } }