Here you can find the source of inputToString(InputStream inputStream, String encoding)
public static String inputToString(InputStream inputStream, String encoding) throws IOException
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import android.text.TextUtils; public class Main { public static String inputToString(InputStream inputStream, String encoding) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = inputStream.read(buffer)) != -1) { bos.write(buffer, 0, len);//from ww w .ja v a 2 s .com } inputStream.close(); bos.close(); if (TextUtils.isEmpty(encoding)) { encoding = "UTF-8"; } return new String(bos.toByteArray(), encoding); } public static boolean isEmpty(String str) { if (str == null || "".equals(str)) return true; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { return false; } } return true; } }