Home Tutorial Java Corejava Path of source code

 
 

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

Related Tags for Path of source code:


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.