Browse - Programming Tips - What's the difference between separator and pathSeparator in the File class?

Date: 2012jul19
Language: Java

Q.  What's the difference between separator and pathSeparator in the File class?

A.  The names are a bit confusing.

separator is the slash in something like this "/usr/local/bin".

pathSeparator is the colon in the $PATH environment variable - eg "/bin:/usr/local/bin"

On Windows separator is a backslash and pathSeparator is a semicolon.

A handy use for these:

String myfullpath = mydir + File.separator + mybasename;