Java File Extension Name Get getFileExtension(String fileName)

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

Description

get File Extension

License

Apache License

Declaration

public static String getFileExtension(String fileName) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    public static final char EXTENSION_SEPARATOR = '.';

    public static String getFileExtension(String fileName) {
        String ext = null;//  w ww . j a  va 2s. co  m
        int k = fileName.lastIndexOf(EXTENSION_SEPARATOR); // NOI18N
        if (k != -1) {
            ext = fileName.substring(k + 1, fileName.length());
        }
        return ext;
    }

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

Related

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