Java File Name Get getFileName(File f)

Here you can find the source of getFileName(File f)

Description

get File Name

License

Open Source License

Declaration

public static String getFileName(File f) 

Method Source Code

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

public class Main {
    public static String getFileName(File f) {
        String ext = null;/*  w w  w  .  j a  va 2  s  .  co  m*/
        String s = f.getName();
        int i = s.lastIndexOf(File.pathSeparatorChar);

        if (i > 0 && i < s.length() - 1) {
            ext = s.substring(i + 1).toLowerCase();
        }
        return ext;
    }
}

Related

  1. getFileName(Class cls, String ext)
  2. getFileName(File element)
  3. getFileName(File f)
  4. getFileName(File f)
  5. getFileName(File file)
  6. getFileName(File file)