public static final String pathSeparator 与系统有关的路径分割符
String pathseparator = File.pathSeparator;
System.out.println(pathseparator);// windows打印 ; Linux打印 :
在 UNIX 系统上,此字段为 ':'
;在 Microsoft Windows 系统上,它为 ';'
。
public static final String separator 与系统有关的默认名称分隔符
String separator = File.separator;
System.out.println(separator);// windows打印 \ Linux打印 /
在 UNIX 系统上,此字段的值为 '/'
;在 Microsoft Windows 系统上,它为 '\\'
。
例如
String fileName = "D:\\test";
String filename = "D:"+File.separator+"test";