Java File Name Create fileName(String path)

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

Description

returns the filename from the given path

License

Apache License

Declaration

public static String fileName(String path) 

Method Source Code

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

public class Main {
    /**/*from ww w  .  j a  v  a2s. c  o m*/
     * returns the filename from the given path
     */
    public static String fileName(String path) {
        int pos = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
        if (pos > 0) {
            return path.substring(pos + 1);
        }
        return path;
    }
}

Related

  1. fileName(String filename)
  2. filename(String filename)
  3. filename(String name)
  4. fileName(String name)
  5. filename(String name, String ext)
  6. fileName(String path)
  7. fileName(String path)
  8. filename(String prefix, String sep, String index)
  9. FileName(String[] args)