RFR: 8298318: (fs) APIs for handling filename extensions [v2]
Brian Burkhalter
bpb at openjdk.org
Wed Mar 6 22:25:58 UTC 2024
On Mon, 20 Nov 2023 23:30:45 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`.
>
> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>
> - 8298318: Correct type in path.getExtension spec
> - Merge
> - 8298318: (fs) APIs for handling filename extensions
Commit b7f00bb37a99a6ec7c6ff4b2bfa3c914b028925b updates this proposal as follows:
1. `getExtension`: The extension is now considered empty if the prefix of the file name string is a sequence of periods containing the last period instead of if the first character of the file name string is the only period.
2. The `addExtension` and `removeExtension` methods are removed.
3. The `withExtension` and `withoutExtension` methods are added.
4. The `withoutExtension` method has behavior like `removeExtension` but is named so as not to imply modifying an immutable `Path`.
5. The `withExtension` method has behavior like an extension replacement function.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16226#issuecomment-1981936104
More information about the nio-dev
mailing list