Java Path File Extention nio getFileNameNoExtensionFromPath(String modulePath)

Here you can find the source of getFileNameNoExtensionFromPath(String modulePath)

Description

Gets the name of the module, minus the windows file extension if on Windows

License

Open Source License

Parameter

Parameter Description
modulePath a parameter

Return

the test module name

Declaration

public static String getFileNameNoExtensionFromPath(String modulePath) 

Method Source Code


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

import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    /**/*  w  w  w.j  a v  a2  s .  c  om*/
     * Gets the name of the module, minus the windows file extension if on Windows
     * @param modulePath
     * @return the test module name
     */
    public static String getFileNameNoExtensionFromPath(String modulePath) {
        Path path = Paths.get(modulePath);
        String fileNameNoPath = path.getFileName().toString();
        String fileNameNoExtension = fileNameNoPath;
        int extIdx = 0;
        if ((extIdx = fileNameNoPath.lastIndexOf(".")) != -1) {
            fileNameNoExtension = fileNameNoPath.substring(0, extIdx + 1);
        }
        return fileNameNoExtension;
    }
}

Related

  1. getFileextension(Path path)
  2. getFileExtension(Path path)
  3. getFileExtension(Path path)
  4. getFileExtension(Path path)
  5. getFileExtension(Path path)
  6. getFilenameWithoutExtension(Path file)
  7. getFileNameWithoutExtension(Path path)
  8. getFileNameWithoutExtension(Path path)
  9. getFileNameWithoutExtension(String filePath)