Java - ScreenShot


/ Published in: Java



Copy this code and paste it in your HTML
  1. import java.awt.Rectangle;
  2. import java.awt.Robot;
  3. import java.awt.Toolkit;
  4. import java.awt.image.BufferedImage;
  5. import java.io.File;
  6.  
  7. import javax.imageio.ImageIO;
  8.  
  9. public class screen2image
  10. {
  11. public static void main(String[] args) throws Exception
  12. {
  13. Robot robot = new Robot();
  14.  
  15. BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
  16. ImageIO.write(screenShot, "JPG", new File("screenShot.jpg"));
  17. }
  18. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.