java实现将base64编码转图片

直接上代码:

 /**
     * Base64转换为图片服务
     * targetPath  输出视频文件路径,不需要文件名
     * */
    public static void base64ToImg(String base64,String targetPath){
        File file = null;
        FileOutputStream fops = null;
        base64 = base64.replace("data:image/jpeg;base64,","");
        byte[] buff = DatatypeConverter.parseBase64Binary(base64);
        try {
            fops = new FileOutputStream(new File(targetPath));
            fops.write(buff);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("--------------------------------"+"图片转换完成"+"--------------------------------");
    }

实现图片转base64链接


版权声明:本文为weixin_45151960原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。