Home Java Java-get-example Java get Absolute Path



Java get Absolute Path
Posted on: November 6, 2008 at 12:00 AM
In this section, you will study how to obtain the absolute path of a particular file. For this, we have define a file 'MainClass.java'. The method file.getAbsolutePath() returns the absolute path of the given file.

Java get Absolute Path

     

In this section, you will study how to obtain the absolute path of a particular file. For this, we have define a file 'MainClass.java'. The method file.getAbsolutePath() returns the absolute path of the given file.

 

 

 

Here is the code of GetAbsolutePath.java

import java.io.File;

public class GetAbsolutePath {
  public static void main(String args[]) {
  File file = new File("MainClass.java");
  System.out.println("Absolute Path: " + file.getAbsolutePath());
 }
}

Output will be displayed as:

Download Source Code

Related Tags for Java get Absolute Path:
javacfileclasspathiomethodtabsgetreturnthisaitabdefineforstudytoeilmainsectionulartabsoluteinpartasmparjclicumehowsurnsoatincishallivarrtvassthavstabfinmainclassonolo


More Tutorials from this section

Ask Questions?    Discuss: Java get Absolute Path  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.