Here you can find the source of convertStreamToString(InputStream is)
private static String convertStreamToString(InputStream is)
//package com.java2s; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; public class Main { private static String convertStreamToString(InputStream is) { /*//from w ww. j a va2 s. c o m * To convert the InputStream to String we use the * BufferedReader.readLine() method. We iterate until the BufferedReader * return null which means there's no more data to read. Each line will * appended to a StringBuilder and returned as String. */ StringBuilder sb = new StringBuilder(); try { BufferedReader reader = new BufferedReader( new InputStreamReader(is, "UTF-8")); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } } catch (Exception e) { e.printStackTrace(); } finally { try { is.close(); } catch (Exception e) { e.printStackTrace(); } } return sb.toString(); } }