public static String getSuffixFromPath(String path) {
        String n = getName(path);
        int i = n.lastIndexOf(".");
        //arbitrarily sets max extension length
        if (i > -1 && n.length() - i < 6) {
            String suffix = n.substring(i);
            if (ASCII_NUMERIC.matcher(suffix).matches()) {
                return suffix;
            }
        }
        return StringUtils.EMPTY;
    }
This includes the period, e.g. ".pdf".
This requires that an extension contain only ascii alphanumerics
and it requires that an extension length be 5 or less.
@param path
@return the suffix or an empty string if one could not be found
tika-core/src/main/java/org/apache/tika/io/FilenameUtils.java