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

/**
 * Created by http://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:

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.