Java手册
separatorChar
复制代码
1public static final char separatorChar
-
与系统有关的默认名称分隔符。此字段被初始化为包含系统属性
file.separator
值的第一个字符。在 UNIX 系统上,此字段的值为'/'
;在 Microsoft Windows 系统上,它为'\'
。-
另请参见:
-
System.getProperty(java.lang.String)
-
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26import java.io.File; public class FileDemo5 { public static void main(String[] args) { // 在Windows中,分隔目录用的 // 在Linux中,分隔目录用的/ // 在Windows中,分隔路径用的; // 在Linux中,分隔路径用的: // pathSeparatorChar 代表 : // separatorChar 代表 / File file = new File("E:" + File.separatorChar + "aaa.txt"); // 获取父路径 System.out.println(file.getParent()); System.out.println(file.getName()); // 获取绝对路径 System.out.println(file.getAbsolutePath()); // 获取路径 System.out.println(file.getPath()); } }
转载于:https://www.cnblogs.com/chuijingjing/p/9521920.html
最后
以上就是单薄猎豹最近收集整理的关于Java separatorChar 如何在Java里面添加 \的全部内容,更多相关Java内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复