Android InputStream to String Convert stringFromInputStream(InputStream is)

Here you can find the source of stringFromInputStream(InputStream is)

Description

string From Input Stream

Declaration

static public String stringFromInputStream(InputStream is) 

Method Source Code

//package com.java2s;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    static public String stringFromInputStream(InputStream is) {
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();

        String line = null;/*from w  ww . j a  v  a2  s  . c  o m*/
        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();
    }
}

Related

  1. convertStreamToString(InputStream is)
  2. convertStreamToString(InputStream is)
  3. convertStreamToString(java.io.InputStream is)
  4. convertStreamToString(java.io.InputStream is)
  5. streamToString(InputStream is)
  6. getStringFromInputStream(InputStream is)