Dave's Brain

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;

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.