Write code to read InputStream and return a string
//package com.book2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readStream(final InputStream pStream) throws IOException { InputStreamReader isr = new InputStreamReader(pStream); BufferedReader br = new BufferedReader(isr); StringBuffer buf = new StringBuffer(); String line = br.readLine(); buf.append(line);//from w w w. j a v a2 s . c o m while ((line = br.readLine()) != null) { buf.append("\n"); buf.append(line); } return buf.toString(); } }