Android InputStream to String Convert readInputStream(InputStream inStream)

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

Description

read Input Stream

Declaration

public static byte[] readInputStream(InputStream inStream)
            throws Exception 

Method Source Code

//package com.java2s;

import java.io.ByteArrayOutputStream;

import java.io.InputStream;

public class Main {
    public static byte[] readInputStream(InputStream inStream)
            throws Exception {
        ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
        byte[] buffer = new byte[4096];
        int len = 0;
        while ((len = inStream.read(buffer)) != -1) {
            outSteam.write(buffer, 0, len);
        }//from   w ww .  j a  va 2s .co  m
        outSteam.close();
        inStream.close();
        return outSteam.toByteArray();
    }
}

Related

  1. convertStreamToText(InputStream is)
  2. convertToString(InputStream is, String encoding)
  3. convertToString(InputStream is, String encoding)
  4. convertToString(InputStream is, String encoding)
  5. convert(InputStream is)
  6. toString(InputStream is)
  7. toStringBuffer(InputStream is)
  8. inputStream2String(InputStream in)
  9. inputStreamToString(InputStream in)