Java File Name Get getFileNameWithoutExtension(final String filePath)

Here you can find the source of getFileNameWithoutExtension(final String filePath)

Description

returns file name "/tmp/abc.txt" returns "abc"

License

Open Source License

Declaration

public static String getFileNameWithoutExtension(final String filePath) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    /**// www . jav  a2  s. c  o m
     * returns file name "/tmp/abc.txt" returns "abc"
     */
    public static String getFileNameWithoutExtension(final String filePath) {
        final File file = new File(filePath);
        String fileName = file.getName();
        fileName = fileName.replace(" ", "_");
        final int index = fileName.lastIndexOf('.');
        return fileName.substring(0, index);
    }
}

Related

  1. getFileNameWithoutExtension(File file)
  2. getFileNameWithoutExtension(File fx)
  3. getFilenameWithoutExtension(final File file)
  4. getFileNameWithoutExtension(final File file)
  5. getFilenameWithoutExtension(final String fileName)
  6. getFileNameWithoutExtension(String fileName)
  7. getFileNameWithoutExtension(String filePath)
  8. getFileNameWithoutExtension(String filePath)
  9. getFileNameWithoutExtension(String filePath)