File.separator vs File.pathSeparator

See: http://stackoverflow.com/questions/5971964/file-separator-vs-pathseparator

 

File.separator 是filePath分隔符, 如 \

File.pathSeparator 是filePathList分割符, 如 ;

 

实验代码

public static void testFile(){
        System.out.println("Operation System: \t" + System.getProperty("os.name"));
        System.out.println("File.separator: \t" + File.separator);
        System.out.println("File.pathSeparator: \t" + File.pathSeparator);
}

 输出结果:

Windows 7
Operation System: Windows 7
File.separator: \
File.pathSeparator: ;

 

Linux
Operation System: Linux
File.separator: /
File.pathSeparator: :

 

你可能感兴趣的:(File)