Here you can find the source of inputStreamToString(InputStream inputstream)
public static String inputStreamToString(InputStream inputstream) throws IOException
//package com.java2s; import java.io.*; public class Main { public static String inputStreamToString(InputStream inputstream) throws IOException { InputStreamReader inputstreamreader = new InputStreamReader( inputstream);//from w w w . j a v a 2 s. co m BufferedReader bufferedreader = new BufferedReader( inputstreamreader); StringBuilder stringbuilder = new StringBuilder(); do { String s = bufferedreader.readLine(); if (s != null) { String s1 = (new StringBuilder()).append(s).append("\n") .toString(); StringBuilder stringbuilder1 = stringbuilder.append(s1); } else { bufferedreader.close(); return stringbuilder.toString(); } } while (true); } }