Here you can find the source of inStream2String(InputStream is)
public static String inStream2String(InputStream is) throws Exception
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.InputStream; import android.util.Log; public class Main { private static final String TAG = "StringUtil"; public static String inStream2String(InputStream is) throws Exception { ByteArrayOutputStream baos = null; try {/*from w ww.j a v a2 s . c om*/ baos = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int len = -1; while ((len = is.read(buf)) != -1) { baos.write(buf, 0, len); } return new String(baos.toByteArray()); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); return null; } finally { if (baos != null) { try { baos.close(); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } } } } }