Android InputStream to Byte Array Convert getBytes(InputStream inputStream)

Here you can find the source of getBytes(InputStream inputStream)

Description

get Bytes

License

Open Source License

Declaration

public static byte[] getBytes(InputStream inputStream)
            throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static byte[] getBytes(InputStream inputStream)
            throws IOException {
        ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
        int bufferSize = 1024;
        byte[] buffer = new byte[bufferSize];
        int len = 0;
        while ((len = inputStream.read(buffer)) != -1) {
            byteBuffer.write(buffer, 0, len);
        }/*from  w  w  w .j  a v a 2  s.c  o  m*/
        return byteBuffer.toByteArray();
    }
}

Related

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