RFR 8057113: (fs) Path should have a method to test the filename extension

Daniel Fuchs daniel.fuchs at oracle.com
Mon Feb 19 10:23:07 UTC 2018


Hi Brian,

On 16/02/2018 22:00, Brian Burkhalter wrote:
> I did check some of those. In particular
> 
> $ basename ..foo
> 
> gives “..foo”.
> 

To my great dismay:

$ basename ..foo .foo
.

But I'm not sure we want to go this route.
This seems very misleading. I'd prefer it
returned "..foo".


> I’ve kept picking away at this and the revised verbiage du moment is
> 
>      * Returns the extension of this {@code Path} as a {@code String}. The
>      * extension is the suffix of the {@link #getFileName file name} element
>      * after the last dot ({@code '.'}). If however the file name is
>      * {@code null}, does not contain a dot, has a dot as its first character,
>      * the last dot is preceded only by dots, or the last character is a dot,
>      * then this method returns an empty {@code String}.
> 
> I hope that makes better sense.
> 

So if I read this correctly getExtension(".x.y") would
yield "" by virtue of finding a dot as first character?
(which I think is fine)

But in this case wouldn't "the last dot is preceded only by dots,
or the last character is a dot" be redundant? Because
".....foo" also has a dot as first character, and
"" is the suffix after the last dot in "blah."

best regards,

-- daniel


More information about the nio-dev mailing list