How to get current working directory in java?

You can get current working directory using System.getProperty("user.dir") function. Here current working directory means the root folder of your current Java project.

Below java code shows how to get current working directory of user –

/****************************************************************************************
* Created on 04-2012 Copyright(c) https://kodehelp.com All Rights Reserved.
****************************************************************************************/
package com.kodehelp.javaio;

/**
 * Created by https://kodehelp.com Date: 4/5/12
 */
public class GetCurrentWorkingDirectory {
    public static void main(String args[]) {
        String workingDirectory = System.getProperty("user.dir");
        System.out.println("Your Current Working Directory is ::" + workingDirectory);
    }
}

References: