Removed try catch and set to throw the exception

This commit is contained in:
Sameera 2016-10-18 22:49:09 +05:30
parent 8fb51bdfd6
commit 3e31921e49
1 changed files with 6 additions and 10 deletions

View File

@ -20,16 +20,12 @@ public class Screenshot {
this.timeToWait = timeToWait; this.timeToWait = timeToWait;
} }
public void getScreenshot() { public void getScreenshot() throws Exception {
try { Thread.sleep(timeToWait);
Thread.sleep(timeToWait); Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); Robot robot = new Robot();
Robot robot = new Robot(); BufferedImage img = robot.createScreenCapture(rectangle);
BufferedImage img = robot.createScreenCapture(rectangle); ImageIO.write(img, fileType, setupFileNamePath());
ImageIO.write(img, fileType, setupFileNamePath());
} catch (Exception ex) {
System.out.println("Error occurred while getting the Print Screen.");
}
} }
private File setupFileNamePath() { private File setupFileNamePath() {