corejava 实现验证码随机生成
public static InputStream change(BufferedImage image) throws Exception{
//将image图片压缩成JPEG
ByteArrayOutputStream bos =
new ByteArrayOutputStream();
JPEGImageEncoder encode =
JPEGCodec.createJPEGEncoder(bos);
encode.encode(image);
//将bos中存储的JPEG格式图片字节取出
byte[] bytes = bos.toByteArray();
return new ByteArrayInputStream(bytes);
}