RFR: 8057113: (fs) Path should have a method to obtain the filename extension [v3]
Brian Burkhalter
bpb at openjdk.java.net
Thu Mar 11 03:00:08 UTC 2021
On Wed, 24 Feb 2021 22:47:51 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Choice 3, the equivalent of getOrDefault, is compact and exposes explicitly the case where no extension is present with very little overhead.
>
> Most use cases appear to concern switching on the extension to select among several alternatives:
>
> - Get the file format name.
> - Get an image reader to read a given image file.
> - Get an icon to represent a given file in a file view.
> - Select an application which can open a file of a certain type.
>
> For this a string-based `getExtension()` method would seem to be enough. It is unclear how a platform representation would add any value or even whether one could be self-consistent given that an extension is not really an element in the sense of a root component, directory, or file. Each of these represents an actual component in the file system whereas an extension could be considered a sort of attribute.
>
> Another related operation would be to remove the extension. A couple of uses of this are:
>
> - Input file `archive.zip` unzips to `archive/`.
> - Input file `archive.tar.gz` gunzips to `archive.tar`.
Next up for this one would be a test and CSR once the basic idea is agreed upon. Are there any more comments to this effect?
-------------
PR: https://git.openjdk.java.net/jdk/pull/2319
More information about the nio-dev
mailing list