Here you can find the source of inputStreamToString(InputStream stream)
public static String inputStreamToString(InputStream stream)
//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 inputStreamToString(InputStream stream) { try {// w w w . jav a 2 s .c om BufferedReader reader = new BufferedReader( new InputStreamReader(stream), 8192); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { if (line.trim().length() > 0) { sb.append(line); } } return sb.toString(); } catch (IOException e) { e.printStackTrace(); } return ""; } }