RFR: 8298318: (fs) APIs for handling filename extensions
Roger Riggs
rriggs at openjdk.org
Thu Nov 2 19:11:03 UTC 2023
On Tue, 17 Oct 2023 19:52:14 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Add to `java.nio.file.Path` a method `getExtension` to retrieve the `Path`'s extension, and companion methods `removeExtension` and `addExtension`.
The use of `withExtension("")` would be equivalent to `withoutExtension()` so the later could be omitted for a simpler API.
And I think that's a reasonable simplification; replacing the extension is much more frequent operation than than dropping the extension.
The spec will need to explain/define how to trim off the extension, so the new extension can be added.
But it could be defined in terms of `path.getFileName()` and perhaps `path.resolveSibling`.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16226#issuecomment-1791393901
More information about the nio-dev
mailing list