我正在尝试捕获HTML页面的屏幕截图。当我在本地主机上运行应用程序时,我正在保存正确的图像。但是,当我在服务器中运行应用程序时,我正在保存黑色图像。任何人都可以告诉我为什么会这样。提前谢谢。
try {
Robot robot = new Robot();
String format = "jpg";
String fileName = "FullScreenshot." + format;
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage screenFullImage = robot.createScreenCapture(screenRect);
ImageIO.write(screenFullImage, format, new File("H:\\" + fileName));
System.out.println("A full screenshot saved!");
}
catch (IOException ex)
{
System.err.println(ex);
}