Android InputStream Read readInputStream(InputStream inputStream)

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

Description

read Input Stream

Declaration

public static String readInputStream(InputStream inputStream)
            throws IOException 

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 readInputStream(InputStream inputStream)
            throws IOException {

        String responseLine;/*from   www  . j a  v a  2  s .com*/
        StringBuilder responseBuilder = new StringBuilder();

        if (inputStream == null) {
            return responseBuilder.toString();
        }

        BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(inputStream));

        try {

            while ((responseLine = bufferedReader.readLine()) != null) {
                responseBuilder.append(responseLine);
            }

        } catch (OutOfMemoryError e) {
            e.printStackTrace();
            return null;
        }

        return responseBuilder.toString();
    }
}

Related

  1. readAllNoClose(InputStream is)
  2. readBSInt(InputStream is)
  3. readFully(InputStream inputStream)
  4. readFullyAndClose(InputStream is)
  5. readInputStream(InputStream inStream)
  6. readInputStream(InputStream is)
  7. readInputStreamContent(InputStream inputStream)
  8. readInt(InputStream stream)
  9. readLong(InputStream in, final int fitInBytes)