Path.equals方法澄清

时间:2013-09-11 09:41:33

标签: java path equals nio

直接来自API

     equals

     boolean equals(Object other)

     Tests this path for equality with the given object.

     If the given object is not a Path, or is a Path associated with a different FileSystem, then this method returns false.

     Whether or not two path are equal depends on the file system implementation. In some cases the paths are compared without regard to
 case, and others are case sensitive. This method does not access the
 file system and the file is not required to exist. Where required, the
 isSameFile method may be used to check if two paths locate the same
 file.

     This method satisfies the general contract of the Object.equals method.

     Overrides:
         equals in class Object
     Parameters:
         other - the object to which this object is to be compared
     Returns:
         true if, and only if, the given object is a Path that is identical to this Path

首先他们说:

1)

  

如果给定对象不是Path,或者是与a关联的Path   不同的FileSystem,则此方法返回false。

然后他们说:

2)

  

此方法不访问文件系统,并且不需要存在该文件。

如果点数 2 为真,那么jvm检查点如何 1

提前致谢。

1 个答案:

答案 0 :(得分:0)

Path表示系统相关的文件路径,但不表示实际文件。它不需要访问文件系统。