Java: toRealPath
Giải phóng thời gian, khai phóng năng lực
Path toRealPath(LinkOption... options) throws IOException
The precise definition of this method is implementation dependent but in general it derives from this path, an absolute
path that locates the same
file as this path, but with name elements that represent the actual name of the directories and the file. For example, where filename comparisons on a file system are case insensitive then the name elements represent the names in their actual case. Additionally, the resulting path has redundant name elements removed.
If this path is relative then its absolute path is first obtained, as if by invoking the toAbsolutePath
method.
The options
array may be used to indicate how symbolic links are handled. By default, symbolic links are resolved to their final target. If the optionNOFOLLOW_LINKS
is present then this method does not resolve symbolic links. Some implementations allow special names such as "..
" to refer to the parent directory. When deriving the real path, and a "..
" (or equivalent) is preceded by a non-"..
" name then an implementation will typically cause both names to be removed. When not resolving symbolic links and the preceding name is a symbolic link then the names are only removed if it guaranteed that the resulting path will locate the same file as this path.
Parameters:
options
- options indicating how symbolic links are handled
Returns:
an absolute path represent the real path of the file located by this object
Throws:
IOException
- if the file does not exist or an I/O error occurs
SecurityException
- In the case of the default provider, and a security manager is installed, its checkRead
method is invoked to check read access to the file, and where this path is not absolute, its checkPropertyAccess
method is invoked to check access to the system propertyuser.dir
Giải phóng thời gian, khai phóng năng lực