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