Android File Extension Name Get getExtension(File file)

Here you can find the source of getExtension(File file)


get Extension


public static String getExtension(File file) 

Method Source Code

//package com.java2s;


public class Main {
    public static String getExtension(File file) {

        int startIndex = file.getName().lastIndexOf(46) + 1;
        int endIndex = file.getName().length();

        return file.getName().substring(startIndex, endIndex);
    }//ww w. java 2 s  .  c  o m


  1. changeExtension(File file, String extensionNew)
  2. getExtension(File file)
  3. getExtension(File file, boolean useFirstPeriod, boolean includePeriod)
  4. getExtension(String file)
  5. getExtension(String filename)
  6. getExtensionName(String fileName)