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

StringconvertStreamToString(InputStream is)
convert Stream To String
Scanner s = new Scanner(is, "utf-8").useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
StringconvertStreamToString(java.io.InputStream is)
convert Stream To String
try {
    return new Scanner(is).useDelimiter("\\A").next();
} catch (java.util.NoSuchElementException e) {
    return "";
StringconvertStreamToString(java.io.InputStream is)
convert Stream To String
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
StringstreamToString(InputStream is)
stream To String
String str = "";
if (is != null) {
    StringBuilder sb = new StringBuilder();
    String line;
    try {
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(is));
        while ((line = reader.readLine()) != null) {
...
StringstringFromInputStream(InputStream is)
string From Input Stream
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();
StringgetStringFromInputStream(InputStream is)
Converts inputStream into String
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
String line;
try {
    br = new BufferedReader(new InputStreamReader(is));
    while ((line = br.readLine()) != null) {
        sb.append(line);
} catch (IOException e) {
    e.printStackTrace();
} finally {
    if (br != null) {
        try {
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
return sb.toString();