The current working directory is the root folder of where your current Java project is running, it can be retrieve by using the system property function.

String workingDir = System.getProperty("user.dir");

Example

package com.mkyong.io;
 
public class App{
 
   public static void main (String args[]) {
 
	   String workingDir = System.getProperty("user.dir");
	   System.out.println("Current working directory : " + workingDir);
 
   }
}

Output

Current working directory : E:\workspace\HibernateExample
This article was posted in Java category.