Android InputStream to Byte Array Convert inputStreamToByte(InputStream is)

Here you can find the source of inputStreamToByte(InputStream is)

Description

input Stream To Byte

Declaration

public static byte[] inputStreamToByte(InputStream is) 

Method Source Code

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

import java.io.InputStream;

public class Main {
    public static byte[] inputStreamToByte(InputStream is) {
        try {/*  w  ww . ja  va2 s .  c o  m*/
            ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
            int ch;
            while ((ch = is.read()) != -1) {
                bytestream.write(ch);
            }
            byte imgdata[] = bytestream.toByteArray();
            bytestream.close();
            return imgdata;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
}

Related

  1. InputStreamTOByte(InputStream in)
  2. InputStreamTOByte(InputStream in)
  3. toByteArray(InputStream is)
  4. toByteArray(InputStream is)
  5. toByteArray(InputStream is)
  6. getBytes(InputStream inputStream)
  7. toByteArray(InputStream is)
  8. streamToByteArray(InputStream paramInputStream)
  9. transStreamToBytes(InputStream is, int buffSize)