public static String InputStream2String(InputStream in, String encoding) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] data = new byte[4096]; int count = -1; try { while((count=in.read(data, 0, 4096)) != -1) { outStream.write(data, 0, count); } } catch (IOException e) { e.printStackTrace(); } data = null; String str = null; try { str = new String(outStream.toByteArray(), encoding); } catch (IOException e) { e.printStackTrace(); } return str; }