Here you can find the source of inputStreamToString(InputStream in)
public static String inputStreamToString(InputStream in)
//package com.java2s; //License from project: Apache License import java.io.InputStream; import java.util.logging.Logger; public class Main { private static final Logger LOG = Logger.getLogger("Utils"); public static String inputStreamToString(InputStream in) { StringBuffer out = new StringBuffer(); byte[] b = new byte[8192]; try {//from ww w .ja v a 2 s . co m for (int n; (n = in.read(b)) != -1;) { out.append(new String(b, 0, n)); } } catch (Exception e) { LOG.severe(e.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception e) { LOG.severe(e.getMessage()); } } } return out.toString(); } }