File getAbsoluteFile() in Java

getAbsoluteFile(): This method is available in the java.io.File class of Java.

Syntax:

File java.io.File.getAbsoluteFile()

This method returns the absolute form of this abstract pathname.

Parameters: NA

Returns: The absolute abstract pathname denoting the same file or directory as This abstract pathname.

Throws:

SecurityException - If a required system property value cannot be accessed.

Approach

Java

import java.io.File;

public class FilegetAbsoluteFile {
    public static void main(String[] args) {

        String pathname = "D:\\hello.txt";
        File file = new File(pathname);

        System.out.println(file.getAbsoluteFile());
    }
}

Output:

D:\hello.txt


No comments:

Post a Comment