tags:

views:

47

answers:

2
+1  Q: 

doubt in file path

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
+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
Don't hard-code "/", use `File.separator` or `System.getProperty("file.separator")`.
Jonathan
"conversion"+File.separator+"is"+File.separator+"more""+File.separator+"convinient"
Basilevs
and there is java.net.URL / File.toURL()
Basilevs