Thursday, June 27, 2024
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:

Nokonwaba Nkukhwana
Experience as a skilled Java developer and proven expertise in using tools and technical developments to drive improvements throughout a entire software development life cycle. I have extensive industry and full life cycle experience in a java based environment, along with exceptional analytical, design and problem solving capabilities combined with excellent communication skills and ability to work alongside teams to define and refine new functionality. Currently working in springboot projects(microservices). Considering the fact that change is good, I am always keen to new challenges and growth to sharpen my skills.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments