I currently have the following code:
ImageIO.write(imageBlue, "PNG", new File("c://imageBlue.PNG"));
But I want the program to write it to my Desktop, no matter when Directory I am currently in.
I currently have the following code:
ImageIO.write(imageBlue, "PNG", new File("c://imageBlue.PNG"));
But I want the program to write it to my Desktop, no matter when Directory I am currently in.
You can use System.getProperty(String) to get the user.home System Property. Then, use that to get the Desktop. Finally, use that to get your desired output File. Something like,
String homeFldr = System.getProperty("user.home");
File desktop = new File(homeFldr, "Desktop");
ImageIO.write(imageBlue, "PNG", new File(desktop, "imageBlue.PNG"));