首页 > 其他 > 详细

Base64String转为图片并保存

时间:2021-03-17 11:32:14      阅读:27      评论:0      收藏:0      [点我收藏+]
 /**
     *
     * @param BASE64str bas64字符串
     * @param path 存储地址
     * @return 存储地址
     */
    public static String BASE64CodeToBeImage(String BASE64str,String path){
        BufferedImage image = null;
        byte[] imageByte = null;
        try {
            imageByte = DatatypeConverter.parseBase64Binary(BASE64str);
            ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
            image = ImageIO.read(new ByteArrayInputStream(imageByte));
            bis.close();
            File outputfile = new File(path);
            ImageIO.write(image, "jpg", outputfile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

  

Base64String转为图片并保存

原文:https://www.cnblogs.com/ycq-qiang/p/14547784.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!