RFR: 8057113: (fs) Path should have a method to obtain the filename extension [v2]
Brian Burkhalter
bpb at openjdk.java.net
Wed Mar 30 23:28:44 UTC 2022
On Mon, 1 Feb 2021 17:53:54 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> src/java.base/share/classes/java/nio/file/Path.java line 259:
>>
>>> 257: * characters, does not contain a dot, only the first character is a dot,
>>> 258: * or the last character is a dot.
>>> 259: *
>>
>> Thanks for bringing this one back. The survey and the current proposal seems reasonable.
>>
>> The spec will need cover the case that the Path doesn't have a file name (getFileName can return null so I assume the prototype implementation will NPE in that case). Are you planning to return null or the empty String for this case?
>>
>> "file name string" needs to be replaced with "the String representation of the file name". This is significant aspect of the proposal in that it aligns the method with toString rather than other operations that preserve the platform representation of the path.
>
> The `getFileName() == null` case was an oversight. I think the empty string should be returned in this case.
Addressed by commit 8d462f8615bc9038a4e27ec5302902f71d558e02.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2319
More information about the nio-dev
mailing list