I am developing a tool, which takes a path of an xml
file. Now that path can be either relative or absolute. Inside the code, when I have only a string, is there a way to identify that the path is absolute or relative?
An absolute path is defined as specifying the location of a file or directory from the root directory(/). In other words,we can say that an absolute path is a complete path from start of actual file system from / directory. Relative path is defined as the path related to the present working directly(pwd).
A path can be absolute or relative. An absolute path contains the full path from the root of the file system down to the file or directory it points to. A relative path contains the path to the file or directory relative to some other path.
How about File.isAbsolute()
:
File file = new File(path); if (file.isAbsolute()) { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With