Android InputStream to Byte Array Convert stream2byte(InputStream inStream)

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

Description

streambyte

Declaration

public static final byte[] stream2byte(InputStream inStream)
            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 final byte[] stream2byte(InputStream inStream)
            throws IOException {
        ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
        byte[] buff = new byte[100];
        int rc = 0;
        while ((rc = inStream.read(buff, 0, 100)) > 0) {
            swapStream.write(buff, 0, rc);
        }//from w  w  w  .j  a  va  2s .co m
        byte[] in2b = swapStream.toByteArray();
        return in2b;
    }
}

Related

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