import sun.misc.BASE64Decoder;
private String getBase64Picture(String imgBase64Str) {
FileOutputStream fos = null;
String uuid = UUID.randomUUID().toString();
String staticPath = "d:/upsoft/test/img/";
String relativePath = "/test/img/";
File cutImgFile = new File(staticPath);
if (!cutImgFile.exists()) {
cutImgFile.mkdirs();
}
String picturePath = staticPath + uuid + ".jpg";
try {
byte[] fileDat = ImageStr2Bytes(imgBase64Str);
File file = new File(picturePath);
fos = new FileOutputStream(file);
fos.write(fileDat);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
return relativePath + uuid + ".jpg";
}
public byte[] ImageStr2Bytes(String imgStr) {
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] b = decoder.decodeBuffer(imgStr);
return b;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}