Android InputStream Read getResponseBody(InputStream inputStream)

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

Description

static utility class to get response String from InputStream

Parameter

Parameter Description
inputStream a parameter

Return

String

Declaration

public static String getResponseBody(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 {
    /**//from   ww  w.  j  a  v  a2  s. c  o  m
     * static utility class to get response String from InputStream
     * @param inputStream
     * @return String
     */
    public static String getResponseBody(InputStream inputStream) {
        String responseString = "";
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    inputStream));
            String myString = "";
            while ((myString = in.readLine()) != null)
                responseString += myString;

            in.close();

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

Related

  1. readTextInputStream(InputStream is)
  2. readData(InputStream inSream, String charsetName)
  3. skip(InputStream stream, int numBytes)
  4. dealResponseResult(InputStream in)
  5. getInputStreamFromUrl_V9( Context paramContext, String paramString)
  6. makeInputStream(Uri uri, ContentResolver cr)
  7. outputFile(InputStream is, String targetPath, String filename)