Android InputStream to String Convert converStreamToString(InputStream is)

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

Description

conver Stream To String

Declaration

public static String converStreamToString(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 {
    public static String converStreamToString(InputStream is) {
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();
        String line = null;//from  w  ww. j  av a 2  s  .  c  om
        try {
            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return sb.toString();
    }
}

Related

  1. inputStreamToString(InputStream is)
  2. inputStreamToString(InputStream stream)
  3. streamToString(InputStream in, String charset)
  4. InputStreamToString(InputStream in)
  5. inputToString(InputStream inputStream, String encoding)
  6. inputStreamToString(InputStream inputStream)
  7. streamToString(InputStream is)
  8. slurp(InputStream in)
  9. convertStreamToString(InputStream is)