I have transferred my code from a method (button press action) to a new class. Its function is to capture screen image (much like print screen) and saves it somewhere in the computer. (in this case, drive c) It displays the following error message:
java.io.FileNotFoundException: c:\z\1.jpg (The system cannot find the path specified)
public class printScreen{
public static void main(String args[]) throws AWTException, IOException
{
Robot robot = new Robot();
Dimension a = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle rect = new Rectangle(a);
BufferedImage img = robot.createScreenCapture(rect);
ImageIO.write(img, "jpg", new File("c:/z/1.jpg"));
ImageIO.write(img, "bmp", new File("c:/z/2.bmp"));
ImageIO.write(img, "png", new File("c:/z/3.png"));
}
}
Any thoughts? All help will greatly be appreciated! Thank you!