Android InputStream to Byte Array Convert streamToByteArray(InputStream paramInputStream)

Here you can find the source of streamToByteArray(InputStream paramInputStream)

Description

stream To Byte Array

Declaration

public static byte[] streamToByteArray(InputStream paramInputStream)
            throws IOException 

Method Source Code

//package com.java2s;

import java.io.ByteArrayOutputStream;

import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static byte[] streamToByteArray(InputStream paramInputStream)
            throws IOException {
        byte[] arrayOfByte = new byte[4096];
        ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
        while (true) {
            int i = paramInputStream.read(arrayOfByte);
            if (i == -1)
                break;
            localByteArrayOutputStream.write(arrayOfByte, 0, i);
        }/*ww  w .j  av a 2 s  . com*/
        return localByteArrayOutputStream.toByteArray();
    }
}

Related

  1. toByteArray(InputStream is)
  2. toByteArray(InputStream is)
  3. inputStreamToByte(InputStream is)
  4. getBytes(InputStream inputStream)
  5. toByteArray(InputStream is)
  6. transStreamToBytes(InputStream is, int buffSize)