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

Model Context Protocol (MCP) — Complete Guide for Backend Engineers

  Model Context Protocol (MCP) — Complete Guide for Backend Engineers Build Tools, Resources, and AI-Driven Services Using LangChain Moder...

Featured Posts