RFR: 8298318: (fs) APIs for handling filename extensions
Stuart Marks
smarks at openjdk.org
Thu Nov 9 05:18:57 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 current state of the `removeExtension` code drops the parent part of the path if there is no extension or if there is an empty extension (i.e., trailing dot):
jshell> Path.of("a/foo").removeExtension()
$3 ==> foo
jshell> Path.of("a/foo.").removeExtension()
$4 ==> foo.
Probably need to add test cases for this.
I have additional questions about whether a trailing dot should or shouldn't be removed in this case; but maybe that's still currently being discussed? Not sure where that stands at the moment.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16226#issuecomment-1803176423
More information about the nio-dev
mailing list