Home Java Java-get-example Java get Absolute Path
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Java get Absolute Path

Advertisement
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

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 6, 2008

Related Tutorials

Ask Questions?    Discuss: Java get Absolute Path  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com