FileInputStream to byte array in Android application

前端 未结 4 1246
梦如初夏
梦如初夏 2020-12-17 16:00

I have a FileInputStream created using Context.openFileInput(). I now want to convert the file into a byte array.

Unfortunately, I can\'t determine the

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-17 16:21

    For the method to work on any device and aplication you just need to replace:

    InputStream is = Context.getContentResolver().openInputStream(yourFileURi);
    

    This way you can encode external files as well.

提交回复
热议问题