Java File Extension Name Extract extractFileExtension(String filename)

Here you can find the source of extractFileExtension(String filename)

Description

extract File Extension

License

Open Source License

Declaration

public static String extractFileExtension(String filename) 

Method Source Code

//package com.java2s;

public class Main {
    public static String extractFileExtension(String filename) {
        int lastslash = filename.lastIndexOf("/");
        if (lastslash != -1)
            filename = filename.substring(lastslash + 1);
        lastslash = filename.lastIndexOf("\\");
        if (lastslash != -1)
            filename = filename.substring(lastslash + 1);
        int lastdot = filename.lastIndexOf(".");
        if (lastdot != -1)
            return filename.substring(lastdot + 1);
        else/*from  ww  w  .  j  a  va  2  s  . c  o  m*/
            return "";
    }
}

Related

  1. extractFileExt(String _sFilePathName)
  2. extractFileExt(String filePath)
  3. ExtractFileExtension(String file_name)
  4. extractFileExtension(String filename)
  5. extractFileExtension(String fileName)
  6. extractFileExtension(String fileName)
  7. extractFileExtension(String filename)
  8. extractFileExtension(String filename)
  9. extractFileExtension(String filePath)