RFR: 8298318: (fs) APIs for handling filename extensions [v6]

Roger Riggs rriggs at openjdk.org
Mon Mar 11 16:34:05 UTC 2024


On Fri, 8 Mar 2024 17:30:21 GMT, Anthony Vanelverdinghe <duke at openjdk.org> wrote:

> 1. What is the rationale for `Path.of("..mp3").getExtension()` being equal to `""`?

>From my point of view it comes down to whether it is reasonable to consider the string without the extension as the root of a filename of a related file. In this case "." doesn't make sense as the root of file related to ..mp3.
The distinction becomes necessary because "." is overloaded, both as a prefix and as an separator.
Similarly, does replacing the extension with another string result in the Path of a file that is associated with the original.  Given the overloading of ".", it is convenient to consider it a separator between the root and the extension only if the root and extension are not empty.

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

PR Comment: https://git.openjdk.org/jdk/pull/16226#issuecomment-1988693167


More information about the nio-dev mailing list