Here you can find the source of inputStream2String(InputStream in)
public static String inputStream2String(InputStream in)
//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 inputStream2String(InputStream in) { StringBuffer sb = new StringBuffer(); InputStreamReader isr = new InputStreamReader(in); BufferedReader reader = new BufferedReader(isr); try {//from w w w . j av a2s. c o m String line; line = reader.readLine(); while (line != null) { sb.append(line); line = reader.readLine(); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (null != reader) { reader.close(); reader = null; } if (null != isr) { isr.close(); isr = null; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return sb.toString(); } }