Java File Extension Name Get getFileExtension(String fileName)

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

Description

get File Extension

License

Open Source License

Declaration

public static String getFileExtension(String fileName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static String getFileExtension(File file) {
        return getFileExtension(file.getName());
    }//w  w w . j a  v a2 s . c o  m

    public static String getFileExtension(String fileName) {
        int i = fileName.lastIndexOf('.');
        int p = Math.max(fileName.lastIndexOf('/'),
                fileName.lastIndexOf('\\'));
        if (i > p) {
            return fileName.substring(i + 1);
        }
        return "";
    }
}

Related

  1. getFileExtension(final File file)
  2. getFileExtension(final String file)
  3. getFileExtension(final String fullName)
  4. getFileExtension(String file)
  5. getFileExtension(String fileName)
  6. getFileExtension(String fileName)
  7. getFileExtension(String filename)
  8. getFileExtension(String fileName)
  9. getFileExtension(String filename)