java将页面传的base64图片写入找指定路径下
public String GetImg(String img){
String data = img;
String base64Data = data.split(",")[1];
Base64.Decoder decoder = Base64.getDecoder();
byte[] bytes = decoder.decode(base64Data);
FileOutputStream fos = null;
int uuid = Util.getUUID();
String filePath = "D:\\"+uuid+".jpg";
try {
fos = new FileOutputStream(filePath);
fos.write(bytes);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fos != null){
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return filePath;
}