此处报告包含路径(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 [])是未定义的