Resolving empty paths.

Alan Bateman Alan.Bateman at Sun.COM
Fri Jan 8 07:53:35 PST 2010


Brendon McLean wrote:
> :
> Thanks.  It's just one of those use cases I need so often.  For example, if a user needs to create a sub path relative some "project path" then I end up code like this:
>
> File f = projectPath.resolve(packageDir).resolve(file).toFile();
>
> The empty package strikes again!  So obviously, I have to guard against it whenever I find this pattern emerging.
>   
Right, in the above then each invocation of resolve could throw 
InvalidPathException if the input is garbage.

Out of curiosity, is toFile() a method that you have added? This doesn't 
exist in our API as it wouldn't always make sense (for example the Path 
might locate a file in a custom file system).

-Alan.


More information about the nio-dev mailing list