Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Java Program to Find Current Working Directory

  • Last Updated : 29 Oct, 2020

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 :

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

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:

My Personal Notes arrow_drop_up
Recommended Articles
Page :