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 stream)
Input Stream To String
final InputStreamReader input = new InputStreamReader(stream,
        "UTF-8");
final char[] buffer = new char[8192];
final StringBuilder output = new StringBuilder(8192);
try {
    for (int read = input.read(buffer, 0, buffer.length); read != -1; read = input
            .read(buffer, 0, buffer.length)) {
        output.append(buffer, 0, read);
...
StringconvertInputStreamToString(InputStream inputStream)
convert Input Stream To String
BufferedReader bufferedReader = new BufferedReader(
        new InputStreamReader(inputStream));
String line = "";
String result = "";
while ((line = bufferedReader.readLine()) != null)
    result += line;
inputStream.close();
return result;
...
StringconvertStreamToString(InputStream inputStream)
convert Stream To String
BufferedReader reader = new BufferedReader(new InputStreamReader(
        inputStream), 1024);
StringBuilder stringBuilder = new StringBuilder();
String line = null;
try {
    while ((line = reader.readLine()) != null) {
        stringBuilder.append(line + "\n");
} catch (IOException e) {
    e.printStackTrace();
} finally {
    try {
        inputStream.close();
    } catch (IOException e) {
        e.printStackTrace();
return stringBuilder.toString();
StringconvertStreamToString(InputStream inputStream)
convert Stream To String
if (inputStream != null) {
    Writer writer = new StringWriter();
    char[] buffer = new char[1024];
    try {
        Reader reader = new BufferedReader(new InputStreamReader(
                inputStream, "UTF-8"), 1024);
        int n;
        while ((n = reader.read(buffer)) != -1) {
...
StringconvertStreamToString(InputStream is)
Converting input stream content to string
InputStreamReader r = new InputStreamReader(is);
StringWriter sw = new StringWriter();
char[] buffer = new char[1024];
try {
    for (int n; (n = r.read(buffer)) != -1;)
        sw.write(buffer, 0, n);
} finally {
    try {
...
StringconvertStreamToString(InputStream is)
convert Stream To String
StringBuilder sb = new StringBuilder();
try {
    BufferedReader reader = new BufferedReader(
            new InputStreamReader(is, "UTF-8"));
    String line = null;
    while ((line = reader.readLine()) != null) {
        sb.append(line + "\n");
} catch (Exception e) {
    e.printStackTrace();
} finally {
    try {
        is.close();
    } catch (Exception e) {
        e.printStackTrace();
return sb.toString();
StringconvertStreamToString(InputStream is)
convert Stream To String
BufferedReader reader = null;
try {
    reader = new BufferedReader(new InputStreamReader(is, "utf-8"),
            512 * 1024);
} catch (Exception e) {
StringBuilder sb = new StringBuilder();
String line = null;
...
StringconvertStreamToString(InputStream is)
convert Stream To String
BufferedReader reader = new BufferedReader(
        new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
    while ((line = reader.readLine()) != null) {
        sb.append(line + "\n");
} catch (IOException e) {
    e.printStackTrace();
} finally {
    try {
        is.close();
    } catch (IOException e) {
        e.printStackTrace();
return sb.toString();
StringconvertStreamToString(InputStream is)
convert Stream To String
BufferedReader reader = new BufferedReader(
        new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
    while ((line = reader.readLine()) != null) {
        sb.append(line + "\n");
} catch (IOException e) {
    e.printStackTrace();
} finally {
    try {
        is.close();
    } catch (IOException e) {
        e.printStackTrace();
return sb.toString();
StringconvertStreamToString(InputStream is)
convert Stream To String
BufferedReader reader = new BufferedReader(
        new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
    while ((line = reader.readLine()) != null) {
        sb.append(line + "\n");
} catch (IOException e) {
    return null;
} finally {
    try {
        is.close();
    } catch (IOException e) {
        return null;
return sb.toString();