How to take a screenshot save to the project folder and save the path to the Mysql database?

Asked

Viewed 818 times

0

So I have a jsp with form,it converts the image to B64 and sends as string pro Servlet Servlet converts to b643

String stt = request.getParameter("base64img");
        try{
            String parts[] = stt.split(",");
            String imgPart = parts[1];
        BufferedImage image = null;
        byte[] imageByte;
        BASE64Decoder decoder = new BASE64Decoder();
        imageByte = decoder.decodeBuffer(imgPart);
        ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
        image = ImageIO.read(bis);
        bis.close();
        // write the image to a file
        File outputfile = new File("image.png");
        ImageIO.write(image, "png", outputfile);

        }catch(Exception e){
            e.printStackTrace();
        }

And it records the image in the project’s src,??

1 answer

1


Hello, use getAbsolutePath method().

For example:

String diretorio = outputfile.getAbsolutePath();
  • Thank you!!!!!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.