Getting the Parents of file name path in Java
In this section, you will learn how to get the parent directory of the current working directory.
Program uses getParent() method of the File class object to find the parent directory name of the current directory.
Above code returns the parent directory of the file/directory.
This method returns the user's current directory. The getProperty() method is the system method which is imported from the System class of the java.lang.*; package. This method tells about the system property according to the indicating argument. Here, the indicating argument user.dir indicates about the current directory.
Here is the code of the program :