由网友(以女皇的霸气统领整个世界)分享简介:我有以base64格式的图像数据,我想这样的base64字符串,图片(.png)文件转换和保存文件下载到本地文件系统,在我的Android应用程序。请建议我一个解决方案I am having Image data in base64 format, I want to convert this base64 st...
我有以base64格式的图像数据,我想这样的base64字符串,图片(.png)文件转换和保存文件下载到本地文件系统,在我的Android应用程序。请建议我一个解决方案
I am having Image data in base64 format, I want to convert this base64 string to image(.PNG) file and save that file to Local file system in my android application. Please suggest a solution for me
推荐答案
试试这个。
FileOutputStream fos = null;
try {
if (base64ImageData != null) {
fos = context.openFileOutput("imageName.png", Context.MODE_PRIVATE);
byte[] decodedString = android.util.Base64.decode(base64ImageData, android.util.Base64.DEFAULT);
fos.write(decodedString);
fos.flush();
fos.close();
}
} catch (Exception e) {
} finally {
if (fos != null) {
fos = null;
}
}
相关推荐
最新文章