Java File Extension Name Get getFileExtension(File file)

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

Description

get File Extension

License

Open Source License

Declaration

public static String getFileExtension(File file) 

Method Source Code

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

import java.io.*;

public class Main {
    public static String getFileExtension(File file) {
        if (file == null)
            return null;
        int extPos = file.getAbsolutePath().lastIndexOf(".");
        int sepPos = file.getAbsolutePath().lastIndexOf(File.pathSeparator);
        if (extPos == -1)
            return null;
        if (sepPos > extPos)
            return null;
        return file.getAbsolutePath().substring(extPos + 1);
    }/*from   ww  w  . j a  v a  2s.  c om*/
}

Related

  1. getFileExtension(File file)
  2. getFileExtension(File file)
  3. getFileExtension(File file)
  4. getFileExtension(File file)
  5. getFileExtension(File file)
  6. getFileExtension(File file)
  7. getFileExtension(File file, boolean includeDot)
  8. getFileExtension(File file, boolean withDot)
  9. getFileExtension(final File aFile)