import java.util.*; public class Main { public static void main(String[] args) { // to find out where your application is running // (sounds easy but its sometimes tricky) System.out.println("This Java applications working directory is:"); // Java has a list of Properties that it uses for everything // the working directory property is user.dir // you can check it out with: System.out.println(System.getProperty("user.dir")); // you can see all the properties with this: System.out.println(System.getProperties()); // it will just dump them all out in a not // organized way // you can also iterate through all of the properties // and print them out line by linewith: Properties myProps = System.getProperties(); for (Enumeration e = myProps.keys(); e.hasMoreElements();/**/){ String key = (String)e.nextElement(); String value = myProps.getProperty(key); System.out.println(key + " = " + value); } } }
Thursday, September 24, 2009
Java - find the working directory
Labels:
Enumeration,
getProperties,
getProperty,
java,
String,
System,
util
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment