How to get current working directory in java

Last updated on March 19th, 2017 at 10:04 am

Previous
Next
In this post, we will see how to get current working directory in java.
There are two ways to do it.

  • Using property user.dir
  • Using getAbsolutePath()

Using property user.dir

We can use System.getProperty(“user.dir”) to get current working directory path.

When I ran above program, I got below output:

Using getAbsolutePath()

We can use file.getAbos

When I ran above program, I got below output:

Previous
Next

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.

Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog