You can use the System Property to get the user's current workingdirectory, but I don't see anything wrong with your code. Bothversions worked when I tested them.String currentDirectory = System.getProperty("user.dir");