Android InputStream to Byte Array Convert inStream2byte(InputStream inStream)

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

Description

in Streambyte

Declaration

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

Method Source Code

//package com.java2s;
import java.io.ByteArrayOutputStream;

import java.io.InputStream;

public class Main {
    public static byte[] inStream2byte(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);
        }/*from   w  w  w .j  av  a  2s  . c o  m*/
        inStream.close();
        return outStream.toByteArray();
    }
}

Related

  1. readBytes(InputStream s)
  2. readFile(InputStream in, String encoding)
  3. readFile(InputStream in, int size)
  4. stream2byte(InputStream inStream)
  5. inStream2byte(InputStream inStream)
  6. InputStram2byteArray(InputStream in)
  7. getBytes(InputStream is)
  8. readBytes(InputStream in)
  9. InputStreamTOByte(InputStream in)