How to check whether the path is relative or absolute in java?
How about File.isAbsolute()
:
File file = new File(path);
if (file.isAbsolute()) {
...
}
There is another very similar way using Paths operations:
Path p = Paths.get(pathName);
if (p.isAbsolute()) {
...
}