Open In App
Related Articles

Java Program to Find Current Working Directory

Improve Article
Improve
Save Article
Save
Like Article
Like

The getproperty() methods defined in System Class in Java which is used to retrieve the value of the property named in the argument list. This method property is specified by the key which accepts the parameter. If the property does not exist, this version of getProperty returns null.

Syntax :

public static String getProperty(String key)

Parameter :

  • key: key whose system property we want

Returns :

  • System property as specified the key
  • Null: if there is no property present with that key.

Example:

Java




// Java Program to Find 
// current working directory
import java.io.*;
  
public class GFG {
    
    public static void main(String[] args)
    {
  
        // Getting the path of system property
        String path = System.getProperty("user.dir");
  
        // Printing the path of the working Directory
        System.out.println("Working Directory = " + path);
    }
}


Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 29 Oct, 2020
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials