Java File Name Get getFilename(File file)

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

Description

get Filename

License

BSD License

Declaration

public static String getFilename(File file) 

Method Source Code


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

import java.io.File;

public class Main {
    public static String getFilename(File file) {
        return getFilename(file.getName());
    }//from  ww  w .j  a  va2 s  .c  o  m

    public static String getFilename(String file) {
        String name = file;
        int index = name.lastIndexOf("\\");
        if (index > -1) {
            name = name.substring(index + 1, name.length());
        } else {
            index = name.lastIndexOf("/");
            if (index > -1)
                name = name.substring(index + 1, name.length());
        }
        return name;
    }
}

Related

  1. getFileName(File file)
  2. getFilename(File file)
  3. getFileName(File file)
  4. getFileName(File file)
  5. getFilename(File file)
  6. getFilename(File file)
  7. getFileName(File file)
  8. getFileName(File file)
  9. getFileName(File file)