相关疑难解决方法(0)

如何将文件转换为Base64?

此处报告包含路径(sdcard中的路径名,以字符串格式)

File dir = Environment.getExternalStorageDirectory();
File yourFile = new File(dir, report);
String encodeFileToBase64Binary = encodeFileToBase64Binary(yourFile);

private static String encodeFileToBase64Binary(File fileName) throws IOException {
    byte[] bytes = loadFile(fileName);
    byte[] encoded = Base64.encodeBase64(bytes);

    String encodedString = new String(encoded);
    return encodedString;
}
Run Code Online (Sandbox Code Playgroud)

在byte []编码行中得到此错误.对于Base64类型,方法encodeBase64(byte [])是未定义的

base64 android

14
推荐指数
3
解决办法
3万
查看次数

标签 统计

android ×1

base64 ×1