HomeLanguagesJavaJava Program to Find Current Working Directory

Java Program to Find Current Working Directory

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:

RELATED ARTICLES

3 COMMENTS

Most Popular

Dominic
32550 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6926 POSTS0 COMMENTS
Nicole Veronica
12041 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12153 POSTS0 COMMENTS
Shaida Kate Naidoo
7060 POSTS0 COMMENTS
Ted Musemwa
7303 POSTS0 COMMENTS
Thapelo Manthata
7018 POSTS0 COMMENTS
Umr Jansen
7010 POSTS0 COMMENTS