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);



Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.