Android File Extension Name Get getFilenameExtension(String path)

Here you can find the source of getFilenameExtension(String path)

Description

get Filename Extension

Declaration

public static String getFilenameExtension(String path) 

Method Source Code

//package com.java2s;

public class Main {
    private static final String FOLDER_SEPARATOR = "/";
    private static final char EXTENSION_SEPARATOR = '.';

    public static String getFilenameExtension(String path) {
        if (path == null) {
            return null;
        }/*from w  w w. ja v  a  2s  .c om*/
        int extIndex = path.lastIndexOf(EXTENSION_SEPARATOR);
        if (extIndex == -1) {
            return null;
        }
        int folderIndex = path.lastIndexOf(FOLDER_SEPARATOR);
        if (folderIndex > extIndex) {
            return null;
        }
        return path.substring(extIndex + 1);
    }
}

Related

  1. getFileExtension(String filename)
  2. getFileExtension(String filename, String defExt)
  3. getFileExtensionFromName(String filename)
  4. getFileExtensionFromSource(byte[] picHeader)
  5. getFileExtensionFromUrl(String url)
  6. getNameMinusExtension(File file)
  7. getPathExtension(final String path)
  8. getSuffix(String f)
  9. hasExtension(String filename, String extension)