![]() ![]() It also resolves any symbolic links before returning the canonical path. ![]() (Parent directory) to the actual directories. GetCanonicaPath(): This method returns the path which is similar to the absolute path but it also converts. GetAbsolutePath(): This method returns a path that is a fully qualified path (after resolving the path relative to the current directory, if the relative path was used while creating the File object). In short, it is the path using which the File object was first created. GetPath(): This method returns a path that was used to create a File object. ![]() All three methods return a string containing the path information of the file, but they differ from one another. Java File class provides three methods namely getPath, getAbsolutePath and getCanonicalPath. What is the difference between path, absolute path, and canonical path? C:\JavaCodeExamples\workspace\JavaCodeExamples\data.txtĪs you can see from the output, I created the file without specifying the complete path but I when printed the absolute path, it gave the complete path of the file in the file system. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |