Where will the image be saved? [closed]
- by Dummy Derp
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
...
public void captureScreen(String fileName) throws Exception {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screenRectangle = new Rectangle(screenSize);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRectangle);
ImageIO.write(image, "png", new File(fileName));
}
...
Going over this code I found on the internet. I got everything except the part where file is created.
In what format file name should be? Should it be C:/myFolder/myImage.png" or just myImage.png and where will it be saved?
Here is what docs say:
File
public File(String pathname)
Creates a new File instance by
converting the given pathname string into an abstract pathname. If the
given string is the empty string, then the result is the empty
abstract pathname.
Parameters:
pathname - A pathname string
Throws:
NullPointerException - If the pathname argument is null