RFR 8057113: (fs) Path should have a method to test the filename extension

Roger Riggs Roger.Riggs at Oracle.com
Wed Feb 14 18:14:30 UTC 2018

Hi Brian,

Ok, but perhaps we should (separately) fix probeContentType to use the 
same rule
(last occurrence of dot).

Thanks, Roger

On 2/14/2018 10:49 AM, Brian Burkhalter wrote:
>> The java.nio.Files.probeContentType(Path) definition of extension 
>> should be consistent with this.
>> (Or vise-versa)
>>   AbstractFileTypeDetector.getExtension():
>>   * Returns the extension of a file name, specifically the portion of the
>>   * parameter string after the first dot.
>> I agree getExtension() is more generally useful and leave the 
>> matching to the caller.
> I read that before doing this. In the use case prompting this issue 
> the foregoing definition would not work. I have always considered the 
> extension to be that portion of the path after the last dot: "usually 
> the extension is the substring which follows the last occurrence, if 
> any, of the dot character” [1].
> Thanks,
> Brian
> [1] https://en.wikipedia.org/wiki/Filename_extension

More information about the nio-dev mailing list