/*** base64转为图片* 文件路径:到文件夹即可,代码里会在文件夹里生成对应的jpg文件*/ public static String base64ToJpg(String path,String base64){String imageCode =""; if (!imageCode.equals("data:image/jpg;base64,")) { imageCode = "data:image/jpg;base64,"+imageCode }
// 判断文件路径是否存在path = "/opt/upFiles/"+path;File filePath = new File(path);if (!filePath.exists()){filePath.mkdirs();}// 创建文件String jpgFile = path + "/" + UUID.randomUUID() + ".jpg";File file = new File(jpgFile);boolean jpgFileExist = false;try {jpgFileExist = file.createNewFile();log.info("jpg文件创建成功");} catch (IOException e) {log.info("jpg文件创建失败");e.printStackTrace();}if (jpgFileExist){// 解密Base64.Decoder decoder = Base64.getMimeDecoder();// 去掉ba