AW: File.getName() vs. Path.getFileName()

Alan Bateman Alan.Bateman at oracle.com
Thu May 26 11:31:10 PDT 2011


Christian Schlichtherle wrote:
>
> The Javadoc says:
>
>  
>
> @return a path representing the name of the file or directory, or
>
> {@code null} if this path has zero elements
>
>  
>
> This is confusing. How can a path have zero elements? If its "", then 
> it has one element. Constructing it from null should be possible. So 
> this statement should probably simply read:
>
>  
>
> @return a path representing the name of the file or directory
>
A Path that consists solely of a root component has zero name elements.

In your code fragment you created a Path from the empty string and this 
is specified to construct a Path representing the empty path. The empty 
path is specified to consist solely of one name element that is empty.

Does that help?

-Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-discuss/attachments/20110526/67c2aad1/attachment.html 


More information about the nio-discuss mailing list