BAEL-13505 Move articles out of core java - part 2
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.printscreen;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
|
||||
public class Screenshot {
|
||||
|
||||
private final String path;
|
||||
|
||||
public Screenshot(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void getScreenshot(int timeToWait) throws Exception {
|
||||
Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit()
|
||||
.getScreenSize());
|
||||
Robot robot = new Robot();
|
||||
BufferedImage img = robot.createScreenCapture(rectangle);
|
||||
ImageIO.write(img, "jpg", new File(path));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.system;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
public class DetectOS {
|
||||
|
||||
public String getOperatingSystem() {
|
||||
String os = System.getProperty("os.name");
|
||||
System.out.println("Using System Property: " + os);
|
||||
return os;
|
||||
}
|
||||
|
||||
public String getOperatingSystemSystemUtils() {
|
||||
String os = SystemUtils.OS_NAME;
|
||||
System.out.println("Using SystemUtils: " + os);
|
||||
return os;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user