I am using Java for a while and come up with this problem: I use hard-coded paths in windows like
"D:\Java-code\JavaProjects\workspace\eypros\src"
The problem is that I need to escape the backslash character in order to use it with string. So I manually escape each backslash:
"D:\\Java-code\\JavaProjects\\workspace\\eypros\\src"
Is there a way to automatically take the unescaped path and return an escaped java string.
I am thinking that maybe another container besides java string could do the trick (but I don't know any).
Any suggestions?
System.getProperty("file.separator");deals with a lot of the system dependant problems you're going to suffer if you go down this path (but not all). Is there a particular reason you want to lock your program to windows? Personally I would put all your user files within their home directory, which you can get the directory of without any system specific code/as cross platform file separator. So, it is safe to use onWindowsplatform too.