dcsimg

How can I get the current working directory with Java?

Tim Rohaly

The current working directory is stored in the system property "user.dir". The following example shows how to read this system property from your application:

public class userdir {
    public static void main(String[] args) {
        System.out.println("Working Directory = " +
           System.getProperty("user.dir"));
    }
}