How to convert a file to Base64?

后端 未结 7 1379
遥遥无期
遥遥无期 2020-12-06 09:58

Here the report contain the path(pathname in sdcard in string format)

File dir = Environment.getExternalStorageDirectory();
File yourFile = new File(dir, rep         


        
7条回答
  •  一整个雨季
    2020-12-06 10:43

    You can try this.

    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    ...
    byte[] byteArray = byteArrayOutputStream.toByteArray();
    base64Value = Base64.encodeToString(byteArray, Base64.DEFAULT);
    

提交回复
热议问题