Here you can find the source of getInputStreamContent(InputStream i, String encoding)
public static String getInputStreamContent(InputStream i, String encoding)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; public class Main { public static String getInputStreamContent(InputStream i) { return getInputStreamContent(i, "UTF-8"); }/*from w w w .j av a 2 s.c o m*/ public static String getInputStreamContent(InputStream i, String encoding) { if (i != null) { BufferedReader pBr; try { pBr = new BufferedReader(new InputStreamReader(i, encoding)); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); return null; } StringBuffer pSb = new StringBuffer(); int a = -1; try { while ((a = pBr.read()) != -1) { pSb.append((char) a); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return pSb.toString(); } return null; } }