Difference between File.separator and slash in paths

后端 未结 14 1242
执笔经年
执笔经年 2020-11-22 13:15

What is the difference between using File.separator and a normal / in a Java Path-String?

In contrast to double backslash \\\\

14条回答
  •  长情又很酷
    2020-11-22 13:33

    "Java SE8 for Programmers" claims that the Java will cope with either. (pp. 480, last paragraph). The example claims that:

    c:\Program Files\Java\jdk1.6.0_11\demo/jfc
    

    will parse just fine. Take note of the last (Unix-style) separator.

    It's tacky, and probably error-prone, but it is what they (Deitel and Deitel) claim.

    I think the confusion for people, rather than Java, is reason enough not to use this (mis?)feature.

提交回复
热议问题