Home Tutorial Java Corejava Path of source code

 
 

Share on Google+Share on Google+
Path of source code
Posted on: April 21, 2010 at 12:00 AM
Advertisement
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:

Advertisement

Related Tags for Path of source code:


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: April 21, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com