Java File Name Get getFileName(String path)

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

Description

return file name without extension from path

License

LGPL

Declaration

public static String getFileName(String path) 

Method Source Code

//package com.java2s;
/*****************************************************************************
 *                        Shapeways, Inc Copyright (c) 2011
 *                               Java Source
 *
 * This source is licensed under the GNU LGPL v2.1
 * Please read http://www.gnu.org/copyleft/lgpl.html for more information
 *
 * This software comes with the standard NO WARRANTY disclaimer for any
 * purpose. Use it at your own risk. If there's a problem you get to fix it.
 *
 ****************************************************************************/

import java.io.File;

public class Main {
    /**/*from  ww w . ja va  2 s  . com*/
       return file name without extension from path 
     */
    public static String getFileName(String path) {

        String name = new File(path).getName();
        int ind = name.lastIndexOf('.');
        if (ind > 0)
            return name.substring(0, ind);
        else
            return name;
    }
}

Related

  1. getFileName(String path)
  2. getFilename(String path)
  3. getFileName(String path)
  4. getFilename(String path)
  5. getFileName(String path)
  6. getFileName(String path)
  7. getFileName(String path)
  8. getFilename(String path)
  9. getFileName(String s)