Search code examples
javaandroidstreamarraysbufferedinputstream

Java Android: BufferedInputStream to byte Array


Has anyone an idea how to get a BufferedInputStream to a byte[] so that I can make a Bitmap of it?

That's my Stream:

BufferedInputStream stream = new BufferedInputStream(socket.getInputStream());

And that's my byte[]:

byte[] bytes;

Solution

  • uhm... the read() method of the BufferedInputStream will give you the byte[] you need.

    For getting a Bitmap, use the BitmapFactory.decodeStream() method and pass in your BufferedInputStream as a parameter. Good to go ! :)