How to get the current working directory in Java
Published: January 10, 2010 , Updated: May 27, 2010 , Author: mkyong
The current working directory is the root folder of where your current Java project is running, it can be retrieve by using the system property function.
String workingDir = System.getProperty("user.dir");
Example
package com.mkyong.io; public class App{ public static void main (String args[]) { String workingDir = System.getProperty("user.dir"); System.out.println("Current working directory : " + workingDir); } }
Output
Current working directory : E:\workspace\HibernateExample
Any Java questions or problems? please post at this JavaNullPointer.com forum, see you there ~
[...] http://www.mkyong.com/java/how-to-get-the-current-working-directory-in-java/ [...]
nice tip, i’ve subscribed to your rss.
thanks for sharing