Wednesday, August 25, 2010

Get the current working directory in Java

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 UserDirectoryTest 
{     public static void main(String[] args) 
    {         System.out.println("Working Directory = " +            System.getProperty("user.dir"));     } } 
Cheers,
Vinay