RFR: 8057113: (fs) Path should have a method to obtain the filename extension [v3]
Roger Riggs
rriggs at openjdk.java.net
Wed Feb 3 17:52:47 UTC 2021
On Wed, 3 Feb 2021 16:42:39 GMT, Rémi Forax <github.com+828220+forax at openjdk.org> wrote:
>> Thanks for listing down the options. We'll need to spend more time working through potential use cases and narrow down the possible APIs. Having a default value or Optional.orElse has some appeal to cover the cases where the Path does not have a file name or extension.
>
> Using an Optional forces a user to read the javadoc (or worst guess), so i'm not sure it's a good idea to use it here because most people will just want the extension not a long speech about the filename being potentially null.
>
> For me using "" when the extension doesn't exist whatever the reason is more pragmatic.
Choice 3, the equivalent of getOrDefault, is compact and exposes explicitly the case where no extension is present with very little overhead.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2319
More information about the nio-dev
mailing list