get Extension By String File Name
This method will check for the dot ‘.' occurrence in the given filename. If it exists, then it will find the last position of the dot ‘.' and return the characters after that, the characters after the last dot ‘.' known as the file extension. Special Cases:
No extension – this method will return an empty String Only extension – this method will return the String after the dot, e.g. 'gitignore' See www.baeldung.com/java-file-extension Used here to avoid having to use external library
Return
an optional holding the string of the extension or null
Parameters
filename
the name of the file that has the extension