小编use*_*572的帖子

ImageIO写入方法 - javax imageio IIOException无法创建输出流

protected void doGet(HttpServletRequest req, HttpServletResponse response)
        throws IOException, ServletException {
    // Expire response
    try {
        //   
        ByteArrayOutputStream imgOutputStream = new ByteArrayOutputStream();
        byte[] captchaBytes;

        BufferedImage image = new BufferedImage(width, height,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D graphics2D = image.createGraphics();
        Hashtable<TextAttribute, Object> map = new Hashtable<TextAttribute, Object>();
        Random r = new Random();
        String token = Long.toString(Math.abs(r.nextLong()), 36);
        String ch = token.substring(0, 6);
        Color c = new Color(0.6662f, 0.4569f, 0.3232f);
        GradientPaint gp = new GradientPaint(30, 30, c, 15, 25,
                Color.white, true);
        graphics2D.setPaint(gp);
        Font font = new Font("Verdana", …
Run Code Online (Sandbox Code Playgroud)

java servlets javax.imageio

3
推荐指数
1
解决办法
6117
查看次数

标签 统计

java ×1

javax.imageio ×1

servlets ×1