get Extension Name - Android java.io

Android examples for java.io:File Name

Description

get Extension Name

Demo Code

public class Main {

  public static String getExtensionName(String filename) {
    if ((filename != null) && (filename.length() > 0)) {
      int dot = filename.lastIndexOf('.');
      if ((dot > -1) && (dot < (filename.length() - 1))) {
        return filename.substring(dot + 1);
      }// w ww.  j  ava2  s . co m
    }
    return filename;
  }

}

Related Tutorials