Path of source code

This tutorial demonstrate how to get the path of your source code

 
 

Share on Google+Share on Google+

Path of source code

Ads

This tutorial demonstrate how to get the path of your source code

Description: 

This example demonstrate how to get the path of your java program file. The URI represents the abstract pathname and URL construct from URI.

Code:

import java.io.*;
import java.net.*;

public class FileLocation {
  public static void main(String args[]) throws MalformedURLException {
    File file = new File("FileLocation");
    URL url = file.toURI().toURL();
    System.out.printf("%s", url);
  }
}

Output:

Advertisements

Ads

Posted on: April 21, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles