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(File file)
Utility method that gets the extension of a file from its name if it has one
try {
    return getFileExtension(file.getCanonicalPath());
} catch (IOException e) {
    return "";
StringgetFileExtension(File file)
Gets the file extension as a string.
String fileName = file.getName();
return (fileName.lastIndexOf(".") == -1) ? ""
        : fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
StringgetFileExtension(File file)
get File Extension
return getFileExtension(file.getPath());
StringgetFileExtension(File file, boolean includeDelimiter)
Return the extension part given file name.
String result = "";
if (file != null) {
    String absoluteName = file.getAbsolutePath();
    if (absoluteName != null) {
        int delimIndex = absoluteName.lastIndexOf(".");
        if (delimIndex != -1) {
            if (!includeDelimiter) {
                delimIndex++;
...
StringgetFileExtension(File fx)
get File Extension
String path = null;
try {
    path = fx.getCanonicalPath();
} catch (IOException e1) {
    path = fx.getAbsolutePath();
return getFileExtension(path);
StringgetFileExtension(File path)
get File Extension
if (path == null)
    return null;
return getFileNameExtension(path.getName());
StringgetFileExtension(final String fileName)
Identifies the file extension for a given file name and returns the extension part, or an empty string if the file has no extension.
return getFileExtension(File.separatorChar, fileName);
StringgetFileExtension(final String filenamePath)
Retourniert Dateiendung (mit Punkt).
String filename = getFilename(filenamePath);
if (filename.lastIndexOf(".") > 0) { 
    return filename.substring(filename.lastIndexOf("."), filename.length()); 
return ""; 
StringgetFileExtension(String filename)
get File Extension
String extension = "";
int index = filename.lastIndexOf('.');
if (index != -1)
    extension = filename.substring(index);
return extension;
StringgetFileExtension(String fileName)
Returns file's extention.
String ext = null;
if (fileName.lastIndexOf(".") > 0 && fileName.lastIndexOf(".") < fileName.length()) {
    ext = fileName.substring(fileName.lastIndexOf(".") + 1);
return ext;