Reputation: 1932
With the following Code I want to show my programm's location:
String myPath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
On Windows 7 it works perfectly, so I get the following result:
C:/Users/Admin/...
But my Problem is Windows XP. I get following URL:
C:/Dokumente%20und%20Einstellungen/Admin/...
How can I replace this %20
in the code?!
This does not work: myPath.replaceAll("%20"," ")
Upvotes: 2
Views: 81
Reputation: 1238
You can use JFileChooser to find the directory.
String DefaultFolder=new JFileChooser().getFileSystemView().getDefaultDirectory().toString();
Upvotes: 0
Reputation: 22233
myPath.replaceAll("%20"," ");
Does not edit myPath
itself, it returns a string that you need to assign to your variable.
myPath = myPath.replaceAll("%20"," ");
Upvotes: 1