Here you can find the source of readTextInputStream(InputStream is)
public static String readTextInputStream(InputStream is) throws IOException
//package com.java2s; import java.io.*; public class Main { public static String readTextInputStream(InputStream is) throws IOException { if (null == is) return null; StringBuffer strbuffer = new StringBuffer(); String line;/*from w w w. j a v a 2 s. c om*/ BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(is)); while ((line = reader.readLine()) != null) { strbuffer.append(line).append("\r\n"); } } finally { if (reader != null) { reader.close(); } } return strbuffer.toString(); } }