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

StringreadIt(InputStream stream)
Reads an InputStream as an UTF-8 string
BufferedReader br = new BufferedReader(
        new InputStreamReader(stream));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
    sb.append(line + "\n");
br.close();
...
StringinputStream2String(InputStream inputStream)
input Stream String
if (inputStream == null) {
    return null;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int count = 0;
while ((count = inputStream.read(buffer)) >= 0) {
    outputStream.write(buffer, 0, count);
...
StringInputStreamTOString(InputStream in)
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(), "ISO-8859-1");
StringInputStreamTOString(InputStream in)
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(), "ISO-8859-1");
StringInputStreamTOString(InputStream in)
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());
StringInputStreamTOString(InputStream in)
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(), "ISO-8859-1");
StringInputStreamTOString(InputStream in)
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(), "UTF-8");
StringInputStreamTOString(InputStream in)
InputStream 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(), "ISO-8859-1");
...
StringInputStreamTOString(InputStream in, String encoding)
Input Stream TO String
if (in == null) {
    return "";
try {
    StringBuilder sb = new StringBuilder();
    String line;
    BufferedReader reader = new BufferedReader(
            new InputStreamReader(in, 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(), "ISO-8859-1");