java: new File(“”, “name”) != new File(“name”) ? (file constructor with empty string)

后端 未结 5 922
野趣味
野趣味 2021-01-20 22:55

Noticed this today.

Given that a file named \"existing\" exists in the PWD of a java process (windows).

new File(\"existing\").exists() => true
         


        
5条回答
  •  没有蜡笔的小新
    2021-01-20 23:20

    From java.io.File:

    If parent is the empty string then the new File instance is created
    by converting child into an abstract pathname and resolving the result
    against a system-dependent default directory.
    

    There's no mention of what the default directory is.

提交回复
热议问题