Path of source code


 

Path of source code

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

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:

Ads