/**
*
* @param base64Str
* @param path
* @return
*/
public static File base642File(String base64Str, String path) {
if (!StringUtils.isNotBlank(base64Str)) {
return null;
}
if (!StringUtils.isNotBlank(path)) {
return null;
}
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = new byte[0];
try {
b = decoder.decodeBuffer(base64Str);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
OutputStream out = new FileOutputStream(path);
out.write(b);
out.flush();
out.close();
log.info("根据base64字符串 生成图片成功。");
return new File(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}