Java File Extension Name Get getFileExtension(String name)

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

Description

get File Extension

License

Open Source License

Declaration

public static String getFileExtension(String name) 

Method Source Code


//package com.java2s;
import java.io.File;

public class Main {
    public static String getFileExtension(String name) {
        int iIndex = name.lastIndexOf('.');
        if (iIndex >= 0) {
            return name.substring(iIndex);
        }/*from   w  w w.  j a v  a  2  s  .  c om*/
        return null;
    }

    public static String getFileExtension(File file) {
        String name = file.getName();
        return getFileExtension(name);
    }
}

Related

  1. getFileExtension(String fileName)
  2. getFileExtension(String filePath)
  3. getFileExtension(String filePath)
  4. getFileExtension(String filePath)
  5. GetFileExtension(String fname)
  6. GetFileExtension(String path)