Here you can find the source of inputStream2String(InputStream is)
public static String inputStream2String(InputStream is)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static String inputStream2String(InputStream is) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i = -1; try {//from w ww.j a v a 2 s . c o m while ((i = is.read()) != -1) { baos.write(i); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return baos.toString(); } }