I’m making a program in Java which will automatically move all of the .png files off of my desktop to my pictures folder, Now I’ve managed to locate the jar file just using the simple
String path = DesktopCleaner.class.getProtectionDomain().getCodeSource().getLocation().getPath();
And that works fine to find where the jar file is, but I want to locate where the pictures folder is, because it’s obviously going to be different on everyone’s computer.
Is there something like %pictures% I can use? Like there is %appdata%.
In case you were lost in my OTT explanation, I’m basically asking:
How can I locate where the Pictures folder is on someones computer, e.g. I’ll run the function and it will return: C:\Users\User\Pictures.
System.getProperty("user.home")will return the user directory (in your example:C:\Users\User\).Now the relative path to the Pictures folder might vary from one version of Windows to another (I assume this is a Windows specific question).