get Filename Extension - Android java.io

Android examples for java.io:File Name

Description

get Filename Extension

Demo Code


public class Main{

    public static String getFilenameExtension(String path) {
        if (path == null) {
            return null;
        }/*from w w w .j a  va 2  s .  c  om*/
        int sepIndex = path.lastIndexOf(".");
        return (sepIndex != -1 ? path.substring(sepIndex + 1) : null);
    }

}

Related Tutorials