Here you can find the source of inputStream2String(InputStream inputstream)
public static String inputStream2String(InputStream inputstream)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String inputStream2String(InputStream inputstream) { BufferedReader in = new BufferedReader(new InputStreamReader(inputstream)); StringBuffer buffer = new StringBuffer(); String line = ""; try {/* w ww . jav a 2 s . c o m*/ while ((line = in.readLine()) != null) { buffer.append(line); } } catch (Exception e) { return null; } finally { safelyCloseInputStream(inputstream); } return buffer.toString(); } public static void safelyCloseInputStream(InputStream is) { try { if (is != null) { is.close(); is = null; } } catch (IOException e) { } } }