Changing the Current Directory

One of the more common requests I see online from beginners (and from a not-so-beginner just now) is how to change the current directory.  This one is really simple, so here's a quick snippet and the output.

System.out.println(new File(".").getAbsolutePath()); System.setProperty("user.dir", System.getProperty("java.io.tmpdir")); System.out.println(new File(".").getAbsolutePath());

And the output:

/Users/jlee/. /tmp/.

See?  Simple.