An abstract representation of file and directory pathnames.
Windows C:\citi\HR\TransportExpense Meal\test.txt
UNIX /opt/ARIS/CRAFT/craft_logs/test1.txt
OS | separator | pathSeparatorChar | prefix | getName() | getParent() |
UNIX | / | : | / | test1.txt | C:\citi\HR\Transport Expense Meal |
Windows | \ | ; | C:\ | test.txt | /opt/ARIS/CRAFT/craft_logs |
当输入为绝对路径时,返回的都是绝对路径。
当输入为相对路径时:
getPath()返回的是File构造方法里的路径,是什么就是什么,不增不减
getAbsolutePath()返回的其实是user.dir+getPath()的内容,从上面F:\eclipseworkspace\testejb、F:\eclipseworkspace\testejb\..\src\test1.txt、F:\eclipseworkspace\testejb\.\test1.txt可以得出。
getCanonicalPath()返回的就是标准的将符号完全解析的路径