这些彼此相等:
new File("c:\\a")
new File("c:\\a\\")
new File("c:\\a","")
new File("c:\\a\\","")
但是
new File("c:\\a","\\")
不等于他们
但是
new File("c:\\a","\\b")
等于new File("c:\\a","b")
为什么?
最佳答案
JavaDocs for java.io.File
应该清楚这一点。
File(File parent, String child)
Creates a new File instance from a parent abstract pathname and a child pathname string.
File(String pathname)
Creates a new File instance by converting the given pathname string into an abstract pathname.
关于java - 为什么 new File ("c:\\a") 不等于 new File ("c:\\a","\\")?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7202304/