RFR: 8057113: (fs) Path should have a method to obtain the filename extension [v2]

Roger Riggs rriggs at openjdk.java.net
Thu Apr 7 15:53:41 UTC 2022


On Fri, 1 Apr 2022 20:15:17 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Resurrection of the proposal to add a method to obtain the filename extension originated in PR [2319](https://github.com/openjdk/jdk/pull/2319).
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8057113: Fix variable name in @return verbiage

The idea from the potential methods above that an extension is a `Path` is non-intuitive and also harder to use.
It may have some advantages in the implementation but it doesn't make the API easier to use
either because of the necessity to create a Path, `Path.of("jpg");`, to hold an extension or to explicitly convert to string to compare the extension.  There are more and better ways of working with strings than Paths and they should be directly available as methods.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8066


More information about the nio-dev mailing list