Determines whether the pathname of the file or folder is absolute.
Package: java.io
Assembly: vjslib (in vjslib.dll)
public boolean isAbsolute();

Return Value
true if the pathname of the file or folder represented by the File object is absolute; false otherwise.

Example
The following example shows how to determine if a file path is absolute.
// file_isabsolute.jsl
import java.io.*;
public class Program
{
public static void main(String[] args)
{
// Create a File object using C:\MyFile.txt.
File myFile = new File("C:\\MyFile.txt");
// Create a File using YourFile.txt.
File yourFile = new File("YourFile.txt");
// Which of these files have absolute paths?
if (myFile.isAbsolute())
{
System.out.println(myFile.getName() +
" is absolute.");
}
else
{
System.out.println(myFile.getName() +
" is NOT absolute.");
}
if (yourFile.isAbsolute())
{
System.out.println(yourFile.getName() +
" is absolute.");
}
else
{
System.out.println(yourFile.getName() +
" is NOT absolute.");
}
}
}
/*
Output:
MyFile.txt is absolute.
YourFile.txt is NOT absolute.
*/

See Also