Android File Extension Name Get getFileExtension(String filename)

Here you can find the source of getFileExtension(String filename)

Description

get File Extension

License

Apache License

Declaration

static public String getFileExtension(String filename) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    static public String getFileExtension(String filename) {
        return getFileExtension(filename, "");
    }/*from ww  w.  j  a  v a 2 s  .  c o m*/

    static public String getFileExtension(String filename, String defExt) {
        if (filename == null || filename.length() == 0)
            return defExt;
        int pos = filename.lastIndexOf('.');
        if (pos >= 0) {
            return filename.substring(pos + 1);
        }
        return defExt;
    }
}

Related

  1. getFileEx(String filePath)
  2. getFileExt(String fileFullName)
  3. getFileExtByFileName(String fileName)
  4. getFileExtension(String file)
  5. getFileExtension(String fileName)
  6. getFileExtension(String filename, String defExt)
  7. getFileExtensionFromName(String filename)
  8. getFileExtensionFromSource(byte[] picHeader)
  9. getFileExtensionFromUrl(String url)