Java File Naked Name Get getFileNameNoExt(String path)

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

Description

get File Name No Ext

License

Open Source License

Declaration

public static String getFileNameNoExt(String path) 

Method Source Code

//package com.java2s;
/*//from  ww  w  . j  a  v a 2s  . co m
 * Copyright (c) 2006-2012 Nuxeo SA (http://nuxeo.com/) and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Nuxeo - initial API and implementation
 *
 */

import java.io.File;

public class Main {
    public static String getFileNameNoExt(String path) {
        String name = getFileName(path);
        int p = name.lastIndexOf('.');
        if (p == -1) {
            return name;
        }
        return name.substring(0, p);
    }

    public static String getFileName(String path) {
        int p = path.lastIndexOf(File.separator);
        if (p == -1) {
            return path;
        }
        return path.substring(p + 1);
    }
}

Related

  1. extractFileWithoutPath(String input)
  2. fileNameWithoutExtension(String filename)
  3. filenameWithoutExtension(String filename)
  4. getFilenameNoExt(File f)
  5. getFileNameNoExt(File file)
  6. getFileNameNoExtension(File file)
  7. getFileWithoutEnding(String absolutePath)
  8. getFileWithoutExtension(File f)
  9. getFileWithoutExtension(File file)