2

This is my code for converting bitmap to byte array.

 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 image.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
 byte[] bitmapdata = outputStream.toByteArray();

And, I want to pass that array to the FileInputStream. And FileInputStream only accepts File. So I created the byte array to file using FileOutputStream. But FileInputStream did not accepting the File from FileOutputStream. I am new to Android coding.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
Sanket
  • 323
  • 2
  • 5
  • 14

1 Answers1

1

Try This its work fine...

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 image.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
 byte[] bitmapdata = outputStream.toByteArray();
 InputStream is = new ByteArrayInputStream(bitmapdata);
Neeraj Singh
  • 610
  • 9
  • 15
  • Thanks @neeraj-singh for your answer. My interface only accepts `FileInputStream`. Is there any way to do that. – Sanket Sep 12 '15 at 12:25