美文网首页
getCanonicalFile,getAbsolutePath

getCanonicalFile,getAbsolutePath

作者: 我也在努力 | 来源:发表于2019-02-27 10:26 被阅读0次

getCanonicalFile getAbsolutePath getPath - 孤竹的博客 - CSDN博客

结论:

当输入为绝对路径时,返回的都是绝对路径。

当输入为相对路径时:

getPath()返回的是File构造方法里的路径,是什么就是什么,不增不减

getAbsolutePath()返回的其实是user.dir+getPath()的内容,从上面F:\eclipseworkspace\testejb、F:\eclipseworkspace\testejb\..\src\test1.txt、F:\eclipseworkspace\testejb\.\test1.txt可以得出。

getCanonicalPath()返回的就是标准的将符号完全解析的路径

相关文章

网友评论

      本文标题:getCanonicalFile,getAbsolutePath

      本文链接:https://www.haomeiwen.com/subject/codxuqtx.html