Method 1:
File Source=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
try{
FileHandler.copy(Source, new File(".\\shots\\Screenshot.png"));
}
catch(IOException E)
{
E.printStackTrace();
}
Method 2:
TakesScreenshot screenShot=((TakesScreenshot)driver);
File source=screenShot.getScreenshotAs(OutputType.FILE);
try {
FileHandler.copy(scrshot, new File(".\\shots\\Screenshot.png"));
} catch (IOException e) {
e.printStackTrace();
}