RFR: 8297814: (fs) Re-visit Path.getExtension return value

Brian Burkhalter bpb at openjdk.org
Tue Dec 6 18:49:27 UTC 2022


On Tue, 6 Dec 2022 18:15:15 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Revise `java.nio.file.Path::getExtension` never to return `null` and to simplify implementing other path manipulations such as removing and replacing the file name extension.

This proposal would modify the value of the returned extension as shown in this table:

| Path            | #8066             | This PR               |
| --------------- | ------------------| --------------------- |
| “a/b/c/foo.jpg” | "jpg"             | ".jpg"                |
| “a/b/c/foo.”    | "" (empty string) | "." (a single period) |
| “a/b/c/foo”     | `null`            | "" (empty string)     |

Note that the definition of the file name extension is changed to include the extension separator period character ('.', U+002E FULL STOP). For example, for the audio file `Crescent.flac`, the returned string will be `.flac` instead of `flac`.

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

PR: https://git.openjdk.org/jdk/pull/11545


More information about the nio-dev mailing list