Android InputStream to String Convert convertStreamToString(InputStream inputStream)

Here you can find the source of convertStreamToString(InputStream inputStream)

Description

convert Stream To String

Declaration

private static String convertStreamToString(InputStream inputStream) 

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 {
    private static String convertStreamToString(InputStream inputStream) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                inputStream), 1024);//from  ww  w . j a v  a  2  s .  c o m
        StringBuilder stringBuilder = new StringBuilder();

        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                stringBuilder.append(line + "\n");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return stringBuilder.toString();
    }
}

Related

  1. inputStream2String(InputStream in)
  2. inputStreamToString(InputStream in)
  3. inputStreamToString(InputStream is)
  4. InputStreamToString(InputStream stream)
  5. convertInputStreamToString(InputStream inputStream)
  6. convertStreamToString(InputStream inputStream)
  7. convertStreamToString(InputStream is)
  8. convertStreamToString(InputStream is)
  9. convertStreamToString(InputStream is)