Here you can find the source of getFileContent(InputStream is, String encoding)
public static String getFileContent(InputStream is, String encoding) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private final static String DEFAULT_CHARSET = "UTF-8"; public static String getFileContent(String filePath) throws IOException { return getFileContent(filePath, DEFAULT_CHARSET); }/*from ww w . j a va2 s.c o m*/ public static String getFileContent(String filePath, String encoding) throws IOException { BufferedReader buff = new BufferedReader(new InputStreamReader( new FileInputStream(filePath), encoding)); String content = getContent(buff); buff.close(); return content; } public static String getFileContent(File file) throws IOException { return getFileContent(new FileInputStream(file)); } public static String getFileContent(InputStream is) throws IOException { BufferedReader buff = new BufferedReader(new InputStreamReader(is, "UTF-8")); String content = getContent(buff); buff.close(); return content; } public static String getFileContent(InputStream is, String encoding) throws IOException { BufferedReader buff = new BufferedReader(new InputStreamReader(is, encoding)); String content = getContent(buff); buff.close(); return content; } private static String getContent(BufferedReader buff) throws IOException { String line; StringBuffer content = new StringBuffer(); while ((line = buff.readLine()) != null) { content.append('\n'); content.append(line); } return content.substring(1).toString(); } }