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

StringBuildertoStringBuffer(InputStream is)
to String Buffer
if (null == is)
    return null;
BufferedReader in = new BufferedReader(new InputStreamReader(is));
StringBuilder buffer = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
    buffer.append(line).append("\n");
is.close();
return buffer;
StringBuildertoStringBuffer(InputStream is)
to String Buffer
if (null == is) {
    return null;
BufferedReader in = new BufferedReader(new InputStreamReader(is));
StringBuilder buffer = new StringBuilder();
String line = null;
while ((line = in.readLine()) != null) {
    buffer.append(line).append("\n");
...
StringBuildertoStringBuffer(InputStream is)
to String Buffer
if (null == is)
    return null;
BufferedReader in = new BufferedReader(new InputStreamReader(is));
StringBuilder buffer = new StringBuilder();
String line = null;
while ((line = in.readLine()) != null) {
    buffer.append(line).append("\n");
is.close();
return buffer;
StringinputStreamToString(final InputStream is)
input Stream To String
final char[] buffer = new char[0x10000];
final StringBuilder sb = new StringBuilder();
final Reader in = new InputStreamReader(is, "utf-8");
try {
    int read;
    do {
        read = in.read(buffer, 0, buffer.length);
        if (read > 0) {
...
StringconvertStreamToString(InputStream is)
convert Stream To String
BufferedReader reader = new BufferedReader(
        new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
    sb.append(line).append("\n");
reader.close();
...
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");
    if (sb.indexOf("\n") != -1
            && sb.lastIndexOf("\n") == sb.length() - 1) {
        sb.delete(sb.lastIndexOf("\n"), sb.lastIndexOf("\n") + 1);
} 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;
while ((line = reader.readLine()) != null) {
    sb.append(line).append("\n");
reader.close();
...
StringconvertStreamToString(InputStream is)
convert Stream To String
BufferedReader reader = new BufferedReader(
        new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
    sb.append(line).append("\n");
reader.close();
...
StringBuilderconvertStreamToText(InputStream is)
convert Stream To Text
String line = "";
StringBuilder total = new StringBuilder();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
try {
    while ((line = rd.readLine()) != null) {
        total.append(line);
} catch (IOException e) {
...
StringBuilderconvertStreamToText(InputStream is)
convert Stream To Text
String line = "";
StringBuilder total = new StringBuilder();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
try {
    while ((line = rd.readLine()) != null) {
        total.append(line);
} catch (IOException e) {
...