Android InputStream to String Convert inputStreamToString(InputStream stream)

Here you can find the source of inputStreamToString(InputStream stream)

Description

input Stream To String

Declaration

public static String inputStreamToString(InputStream stream) 

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 inputStreamToString(InputStream stream) {
        try {//  w  w  w  . jav a 2 s  .c om
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(stream), 8192);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                if (line.trim().length() > 0) {
                    sb.append(line);
                }
            }
            return sb.toString();

        } catch (IOException e) {
            e.printStackTrace();

        }

        return "";
    }
}

Related

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