Resolving empty paths.
Brendon McLean
java.net at twistedprotein.com
Fri Jan 8 05:38:32 PST 2010
Hi,
I apologise if this has already been discussed, but I could not find a way to search the mailing list, or properly use Google to check for that.
I am already using the Paths API in production code (www.mindsilver.com) as I was reluctant to create my own Jetbrains-like VirtualFile type abstraction when a JDK substitute lies around the corner. I pulled the whole API out and have been using about 50% of it very successfully on Mac, Unix and Linux. I plan to revert to your API when JDK7 is released.
One issue I run into a lot though, is exceptions caused by an "Empty path". Mostly, this happens when resolving the empty string against an absolute path. I see that subsequent to my branching, there is a null guard which will doubtless save many people, but lots of GUIs, whether web or Swing, will use the empty string instead of a null. Would there be any adverse effects of adding a check for the empty string and simply returning "this" from the resolve method in such a case?
i.e. Surely Paths.get("/usr/local").resolve("") should return Paths.get("/usr/local")?
Regards,
Brendon McLean.
Mindsilver Ltd.
More information about the nio-dev
mailing list