You can't use endsWith with regular expressions. Use matches instead:
The (?i) makes the matching case insensitive. Leave it out to have case sensitive matching. You need the leading .* because matches uses exact matching, not substring matching.
currentFile.getName().lastIndexOf('.') would return the index of the last dot, or -1 if there are no dots in the name. If you then add 1, you get the index of the first character after the last dot, or 0. Calling substring from that index on would give you either the extension, or the entire name.