RFR: 8057113: (fs) Path should have a method to obtain the filename extension [v18]

Stuart Marks smarks at openjdk.org
Wed Aug 3 22:26:21 UTC 2022


On Mon, 1 Aug 2022 21:54:22 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Resurrection of the proposal to add a method to obtain the filename extension originated in PR [2319](https://github.com/openjdk/jdk/pull/2319).
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8057113: Remove API note

src/java.base/share/classes/java/nio/file/Path.java line 256:

> 254:      * extension is the portion of the {@linkplain #getFileName file name}
> 255:      * string after the last period character ('.', U+002E FULL STOP). Leading
> 256:      * period characters in the string are ignored. If there is no  extension,

The definition of the extension is in two sentences, first this:

> The extension is the portion of the file name string after the last period character.

Followed by this:

> Leading period characters in the string are ignored.

This is confusing, since the first sentence reads like a complete definition. But the second sentence modifies it, forcing the reader to go back and reinterpret.

I'd suggest putting the definition into a single sentence, something like this:

> The extension is the portion of the _file name_ string
> after the last period character (...) that is not a leading
> period character in the string.

(I've omitted the link and the Unicode callout here for ease of reading, but I think they should be
included in the actual markup, as before.)

(Also, to my ear "dot" reads better than "period" since conventionally a filename like `abc.txt` would be read aloud as "aye bee see dot tee ex tee". But it's ok if you want to stick with period consistently.)

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

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


More information about the nio-dev mailing list