i tried a program comparing C:\Program Files and C://Program Files i checked with compareTo()==0 it comes they are equal. But i doubt if there is any difference between //&\ Is there any difference? what is the difference between c:/program files and //?
+3
A:
There is no difference, at least in Sun's implementation. The Win32FileSystem
normalizes paths by converting slashes and removing duplicate slashes.
If you want to be 100% portable, use File.separator
Bozho
2010-10-18 09:00:47
+1
A:
The separator between path components depends on operating system. Java represents file path independently of operating system and that causes equality of values considered. Conversion to native representation is done on lower level (as Bozho pointed out), and you should not worry about that. Nevertheless I'd recommend using "/" as separator, as it is more common OS-wise.
Basilevs
2010-10-18 09:05:03
Don't hard-code "/", use `File.separator` or `System.getProperty("file.separator")`.
Jonathan
2010-10-18 13:29:22
"conversion"+File.separator+"is"+File.separator+"more""+File.separator+"convinient"
Basilevs
2010-10-18 14:01:22
and there is java.net.URL / File.toURL()
Basilevs
2010-10-18 14:04:00