BufferedImage 转换成 Base64
public static String getBase64(BufferedImage image) throws IOException {
String base64 = null;
//输出流
ByteArrayOutputStream stream = null;
try {
Integer width = image.getWidth();
Integer height = image.getHeight();
System.out.println("宽:" + width + " 高:" + height);
stream = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", stream);
new ByteArrayOutputStream().flush();
base64 = Base64.encode(stream.toByteArray());
System.out.println(base64);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
stream.close();
}
return base64;
}
这个ImageAndUUIDVo类是自己定义的
返回一个UUID和一个验