Java Utililty Methods File Extension Name Extract

List of utility methods to do File Extension Name Extract

Description

The list of methods to do File Extension Name Extract are organized into topic(s).

Method

StringgetFileExtension(String filename, String extensionSeparator)
Returns the extension of a filename.
int extindex = filename.lastIndexOf(extensionSeparator);
if (extindex >= 0)
    return filename.substring(extindex + 1);
return "";
StringgetFileExtension(String filePath)
Get the extension of a file.
return getFileExtension(new File(filePath));
StringgetFileExtensionIgnoringGz(File f)
get File Extension Ignoring Gz
String name = f.getName().toLowerCase();
if (name.endsWith(".gz")) {
    name = name.substring(0, name.length() - 3);
return getFileExtension(name);