The getAbsolutePath() method returns the absolute path of the given file or directory. The method is system-dependent. On Windows OS a relative path is made absolute by resolving ti against the current folder of the drive named by the pathname. On UNIX a relative path is made absolute by resolving the current user directory.
2. Method signature
- method does not take any parameter
- String - the absolute pathname of the given file or directory
- SecurityException - if a required system property value cannot be accessed.
3.1. Program that prints several absolute paths using
.java file was runned under
/home/frontbackend/projects/tutorials directory we will have the following output:
In this article, we showcased the
File.getAbsolutePath() method that returns the absolute path of the specified file or directory. Keep in mind that this method works differently on Windows and Unix OS.