Java File Name Get getFileNameWithoutExtension(File file)

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

Description

Returns name of specified file without its extension.

License

Open Source License

Parameter

Parameter Description
file File to extract name from

Return

name of File

Declaration

public static String getFileNameWithoutExtension(File file) 

Method Source Code

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

import java.io.File;

public class Main {
    /**//from  ww w  . j a v a 2s  .  c om
     * Returns name of specified file without its extension.
     * @param file File to extract name from
     * @return name of File
     */
    public static String getFileNameWithoutExtension(File file) {
        if (file == null) {
            return null;
        }

        String path = file.getName();
        int dotAt = path.lastIndexOf('.');
        if (dotAt < 0) {
            return null;
        }

        return path.substring(0, dotAt);
    }
}

Related

  1. GetFileNameWithoutExt(String file_path)
  2. getFileNameWithoutExt(String fileName)
  3. getFileNameWithoutExt(String filePath)
  4. getFileNameWithoutExt(String originPath)
  5. getFilenameWithoutExtension(File f)
  6. getFileNameWithoutExtension(File file)
  7. getFileNameWithoutExtension(File file)
  8. getFileNameWithoutExtension(File file)
  9. getFileNameWithoutExtension(File file)