java take and save screenshot

Solutions on MaxInterview for java take and save screenshot by the best coders in the world

showing results for - "java take and save screenshot"
Mateo
30 Oct 2018
1BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
2ImageIO.write(image, "png", new File("/screenshot.png"));
3
Jasmine
17 Apr 2018
1public void captureScreen(String fileName) throws Exception {
2   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
3   Rectangle screenRectangle = new Rectangle(screenSize);
4   Robot robot = new Robot();
5   BufferedImage image = robot.createScreenCapture(screenRectangle);
6   ImageIO.write(image, "png", new File(fileName));
7}
8
Laura
20 Apr 2018
1Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
2BufferedImage capture = new Robot().createScreenCapture(screenRect);
3ImageIO.write(capture, "bmp", new File(args[0]));
4