Why is there a PATH_SEPARATOR constant?

前端 未结 3 740
温柔的废话
温柔的废话 2020-12-29 19:49

Isn\'t this / ?

Why is there a constant for it? It\'s not like it can change, right?

3条回答
  •  误落风尘
    2020-12-29 20:20

    As your original question states: "Why is there a PATH_SEPARATOR constant?", windows uses a semi-colon ;, while other systems use a colon :

    However I think you've mistaken PATH_SEPARATOR with DIRECTORY_SEPARATOR

    PATH_SEPARATOR delimits multiple paths in the same string. For example when used in windows environment variables.

    c:\path\to\a;c:\path\to\b

    DIRECTORY_SEPARATOR separates the directories within the path: In Windows

    \
    

    In other systems

    /
    

    As mentioned by others, windows also accepts /

提交回复
热议问题