How to get Current working Directory in java ?

To get current directory location we can use user.dir property

System.getProperty("user.dir")

Example

package com.pretech;
public class CurrentDirectory {
	public static void main(String[] args) {
		System.out.println("Current Directory :"
				+ System.getProperty("user.dir"));
	}
}

No comments:

Post a Comment

12 classic String-based Java interview questions with simple explanations and code.

  1️⃣ Check if a String is a Palindrome Problem Given a string, check if it reads the same forward and backward. Example: "madam...

Featured Posts