Here you can find the source of InputStreamTOString(InputStream in, String encoding)
public static String InputStreamTOString(InputStream in, String encoding) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static String InputStreamTOString(InputStream in, String encoding) throws IOException { return new String(InputStreamTOByte(in), encoding); }// ww w .j a va2s . c o m public static byte[] InputStreamTOByte(InputStream in) throws IOException { int BUFFER_SIZE = 4096; ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] data = new byte[BUFFER_SIZE]; int count = -1; while ((count = in.read(data, 0, BUFFER_SIZE)) != -1) outStream.write(data, 0, count); data = null; byte[] outByte = outStream.toByteArray(); outStream.close(); return outByte; } }