How to create automatic path on a java application -


I'm creating a small application to take a picture of my screen. I can save it on my desktop automatically with this path:

  string file name = "c: \\ user \\ compliant \\ desktop \\" + x + ".png"; ImageIO.write (image, "PNG", new file (FILENAME));  

Where is Obed My username is how can I change the "compliant" on the user's PC name, can I run my application on any computer like this?

You get the user's home directory from the system property user.home Can:

  string FILENAME = System.getProperty ("user home") + "\\ desktop \\" + x + ".png";  

Comments