Android InputStream Read 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 outStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len = 0;
        while ((len = inStream.read(buffer)) != -1) {
            outStream.write(buffer, 0, len);
        }/*www. j av  a  2s.c o m*/
        byte[] data = outStream.toByteArray();
        outStream.close();
        inStream.close();
        return data;
    }
}

Related

  1. readAllBytesToOutput(InputStream is, OutputStream output)
  2. readAllNoClose(InputStream is)
  3. readBSInt(InputStream is)
  4. readFully(InputStream inputStream)
  5. readFullyAndClose(InputStream is)
  6. readInputStream(InputStream inputStream)
  7. readInputStream(InputStream is)
  8. readInputStreamContent(InputStream inputStream)
  9. readInt(InputStream stream)