RFR 8057113: (fs) Path should have a method to test the filename extension
brian.burkhalter at oracle.com
Fri Feb 16 20:20:29 UTC 2018
On Feb 16, 2018, at 10:32 AM, Daniel Fuchs <daniel.fuchs at oracle.com> wrote:
> As David noted, .vimrc is a filename - not an extension,
> and the Unix/Linux basename command will treat it as such:
> $ basename ~/.vimrc .vimrc
> I think we should try to honor this expectation.
> $ basename ~/.vimrc.vimrc .vimrc
Extrapolating it seems that maybe the extension should be empty if the prefix is one or more dots and there are no more dots in what the basename would return. What then do we do about cases such as .java.policy? It seems the result might better be “policy” than empty.
> So would the code below work?
> String filename = Optional.ofNullable(getFilename())
> int index = filename.lastIndexOf('.');
> if (index > 0) return filename.substring(index+1);
> else return ""
It looks like for the aberration “..foo” the above would return “foo” which I am not sure we would want.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nio-dev