Here you can find the source of readInputStream(InputStream inputStream)
public static String readInputStream(InputStream inputStream) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readInputStream(InputStream inputStream) throws IOException { String responseLine;/*from www . j a v a 2 s .com*/ StringBuilder responseBuilder = new StringBuilder(); if (inputStream == null) { return responseBuilder.toString(); } BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream)); try { while ((responseLine = bufferedReader.readLine()) != null) { responseBuilder.append(responseLine); } } catch (OutOfMemoryError e) { e.printStackTrace(); return null; } return responseBuilder.toString(); } }