Android Utililty Methods InputStream to String Convert

List of utility methods to do InputStream to String Convert

Description

The list of methods to do InputStream to String Convert are organized into topic(s).

Method

StringInputStreamTOString(InputStream in, String encoding)
Input Stream TO String
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;
return new String(outStream.toByteArray(), encoding);
StringInputStreamTOString(InputStream in, String encoding)
Input Stream TO String
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;
return new String(outStream.toByteArray(), encoding);
StringInputStreamTOString(InputStream in, String encoding)
This function converts an InputStream in a predefined encoding to a String.
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;
return new String(outStream.toByteArray(), encoding);
StringInputStreamTOString(InputStream in, String encoding)
Input Stream TO String
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;
return new String(outStream.toByteArray(), encoding);
StringInputStreamTOString(InputStream in, String encoding)
InputStream to String with encoding
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;
return new String(outStream.toByteArray(), encoding);
...
StringInputStreamTOStringUTF8(InputStream in)
Input Stream TO String UTF
return InputStreamTOString(in, "UTF-8");
StringtoString(InputStream is)
to String
if (null == is)
    return null;
return toStringBuffer(is).toString();
StringtoString(InputStream is)
to String
int char_ = 0;
ByteArrayBuffer total = new ByteArrayBuffer(0);
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
while ((char_ = rd.read()) != -1) {
    total.append(char_);
String output = new String(total.toByteArray());
return output;
...
StringtoString(InputStream is)
to String
if (null == is) {
    return null;
return toStringBuffer(is).toString();
StringtoString(InputStream is)
to String
if (null == is)
    return null;
return toStringBuffer(is).toString();