java在linux和windows下目录的通用分割符

来源:互联网 发布:vb语言好学吗 编辑:程序博客网 时间:2024/05/18 03:59

linux下目录 /home/holdlg/download
windows下目录 C:\windows\User\holdlg\download
java通用分隔符表示:System.getProperty(“file.separator”) 替代 “/”和”\”

举个例子:

String testStr = "C:\\windows\\User\\holdlg\\download"String[] tmp = test.split(System.getProperty("file.separator"));

参考链接:http://blog.csdn.net/dreamcode/article/details/33331517

0 0
原创粉丝点击