how to take snapshot of browser using selenium

how to take snapshot of browser using selenium

File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File(“snapshot.png”));