public void exportImage(String baseUrl, String imagePath) {
String base64Info = baseUrl;
base64Info = base64Info.replaceAll(" ", "+");
String[] arr = base64Info.split("base64,");
if (arr != null && arr.length > 1) {
byte[] buffer = null;
try {
buffer = Base64.decode(arr[1].getBytes());
} catch (Exception e) {
e.printStackTrace();
}
OutputStream output = null;
try {
output = new FileOutputStream(new File(imagePath));// 生成png文件
output.write(buffer);
output.flush();
output.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
导出png图片
最新推荐文章于 2023-03-30 22:19:13 发布