java 中 file.getpath getabsolutepath和getcanonicalpath的不同

2025-06-26 19:14:57
推荐回答(2个)
回答1:

getAbsolutePath() 得到绝对路径、全路径。
getpath 得到缩写的路径,根据当前目录位置可以缩写路径。得到相对路径。
getCanonicalPath() 得到标准路径,将统一平台间的路径写法差异。

回答2:

前面是得到绝对路径

后面的是抽象 的

getCanonicalPath()
Returns the canonical pathname string of this abstract pathname.