/*
Get Absoulte path of the file
This Java example shows how to get absolute path of a file using getAbsolutePath
method of Java File class.
*/
import java.io.*;
public class GetAbsoulteFilePath {
public static void main(String[] args) {
String filePath = File.separator + "JavaExamples" + File.separator + "IO";
//create new File object
File file = new File(filePath);
/*
* To get absoulte path of the file use,
* String getAbsolutePath() method of File class.
*
* It returns a String containing absoulte path of the file in filesystem.
*/
System.out.println("Abstract file path is :" + file.getPath());
System.out.println("Absolute file path is : " + file.getAbsolutePath());
}
}
/*
Output would be
Abstract file path is :\JavaExamples\IO
Absolute file path is : C:\JavaExamples\IO
*/