I was trying to write a line of code to get the absolute path of the working/current directory. The best I could come up with was this ugly piece of code. How would you make it better? Is there a common idiom?
The thing to remember with the user.dir system variable is that it represents the directory from where the JVM was started, which can be anywhere on the filesystem, and it may or may not be what you're after. You definitely can't depend on it to find out the root of the application.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.