的base64图像数据转换为图像文件(.PNG),并将其保存到本地文件系统转换为、文件系统、图像文件、图像

由网友(以女皇的霸气统领整个世界)分享简介:我有以base64格式的图像数据,我想这样的base64字符串,图片(.png)文件转换和保存文件下载到本地文件系统,在我的Andr​​oid应用程序。请建议我一个解决方案I am having Image data in base64 format, I want to convert this base64 st...

我有以base64格式的图像数据,我想这样的base64字符串,图片(.png)文件转换和保存文件下载到本地文件系统,在我的Andr​​oid应用程序。请建议我一个解决方案

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;
        }
    }
阅读全文

相关推荐

最新文章