阜新网站优化,怎么把网站和域名绑定,英文网站怎么设置中文,自己做网站做外贸可以吗在Windows下的路径分隔符和Linux下的路径分隔符是不一样的#xff0c;当直接使用绝对路径时#xff0c;跨平台会暴出“No such file or diretory”的异常。 比如说要在temp目录下建立一个test.txt文件#xff0c;在Windows下应该这么写#xff1a;File file1 new File (当直接使用绝对路径时跨平台会暴出“No such file or diretory”的异常。 比如说要在temp目录下建立一个test.txt文件在Windows下应该这么写File file1 new File (C:\tmp\test.txt);在linux下则是这样的File file2 new File (/tmp/test.txt); 如果要考虑跨平台则最好是这么写File myFile new File(C: File.separator tmp File.separator, test.txt); File类有几个类似separator的静态字段都是与系统相关的在编程时应尽量使用。 separatorChar public static final char separatorChar 与系统有关的默认名称分隔符。此字段被初始化为包含系统属性 file.separator 值的第一个字符。在 UNIX 系统上此字段的值为 /在 Microsoft Windows 系统上它为 \。 separator public static final String separator 与系统有关的默认名称分隔符为了方便它被表示为一个字符串。此字符串只包含一个字符即 separatorChar。 pathSeparatorChar public static final char pathSeparatorChar 与系统有关的路径分隔符。此字段被初始为包含系统属性 path.separator 值的第一个字符。此字符用于分隔以路径列表 形式给定的文件序列中的文件名。在 UNIX 系统上此字段为 :在 Microsoft Windows 系统上它为 ;。 pathSeparator public static final String pathSeparator 与系统有关的路径分隔符为了方便它被表示为一个字符串。此字符串只包含一个字符即 pathSeparatorChar。 转载于:https://www.cnblogs.com/duan2/p/7485490.html