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

Daniel Fuchs daniel.fuchs at oracle.com
Thu Feb 15 17:04:58 UTC 2018


Hi Brian,

185         String path = toString();

shouldn't this be

String path = getFileName().toString()?

I wonder if the specification of getExtension() should
be defined has being a substring of getFileName()?

best regards,

-- daniel

On 15/02/2018 16:54, Brian Burkhalter wrote:
> http://cr.openjdk.java.net/~bpb/8057113/webrev.01/
> 
> I updated the patch to add to j.n.f.Path
> 
> String getExtension()
> 
> instead of
> 
> boolean hasExtension(String…).
> 
> The previously mentioned use case of a given file type having multiple possible extensions may be trivially handled for example as
> 
> Set.of(“jpg”, “JPG”, “jpeg”).contains(path.getExtension())
> 
> The class javadoc of Path was also updated to put the concept of extension in context.
> 
> Thanks,
> 
> Brian
> 



More information about the nio-dev mailing list