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) All Rights Reserved.
package com.kodehelp.javaio;

 * Created by 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);