First of all, tell the difference:
File.pathseparator refers to separators that separate successive paths of strings, for example:
JAVA-CP Test.jar;abc.jar HelloWorld
That means ";"
File.separator is used to separate directories in the same path string, for example:
C:\Program Files\Common Files
That means "\"
Separatorchar
public static final Char Separatorchar
The system-related default name delimiter. This field is initialized to the first character that contains the system attribute File.separator value . On a UNIX system, the value of this field is '/'; on a Microsoft Windows system, it is ' \ '.
Separator
public static final String separator
The system-related default name delimiter , which is represented as a string for convenience. This string contains only one character, that is, Separatorchar.
Pathseparatorchar
public static final Char Pathseparatorchar
The system-related path delimiter . This field is initially the first character that contains the system attribute Path.separator value. This character is used to separate file names in a sequence of files given as a list of paths . On a UNIX system, this field is ': '; on a Microsoft Windows system, it is '; '.
PathSeparator
public static final String PathSeparator
The system-related path delimiter, for convenience, is represented as a string. This string contains only one character, that is, Pathseparatorchar.
Example:
File ft = new file (file.separator);//point to the drive letter where the current class file is located, for example D:
File ft2 = new file (ft, "file_separator.txt");//D:\File_separator.txt
The difference of pathseparator and separator in Java.io.File