Java File Name Create fileName(String filename)

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

Description

file Name

License

Open Source License

Parameter

Parameter Description
filename The name of the file whose name (without extension) we want

Declaration

public static String fileName(String filename) 

Method Source Code

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

public class Main {
    /***********************************************************
     * @param filename//from ww w  .j a v a  2  s .  co m
     *          The name of the file whose name (without extension) we want
     ***********************************************************/
    public static String fileName(String filename) {
        String name = "";

        int i = filename.lastIndexOf('.');
        int p = Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\'));

        if (i > p) {
            name = filename.substring(0, i);
        }
        return name;
    }
}

Related

  1. filename(final String path)
  2. fileName(String contentFile)
  3. fileName(String file)
  4. fileName(String file, String moduleName)
  5. filename(String filename)
  6. filename(String filename)
  7. filename(String name)
  8. fileName(String name)
  9. filename(String name, String ext)