Here you can find the source of getFileNameWithoutExtension(String filePath)
public static String getFileNameWithoutExtension(String filePath)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static String getFileNameWithoutExtension(String filePath) { if (filePath == null || filePath.trim().length() == 0) { return filePath; }/*from w w w. ja v a 2 s .c o m*/ int extenPosi = filePath.lastIndexOf("."); int filePosi = filePath.lastIndexOf(File.separator); if (filePosi == -1) { return (extenPosi == -1 ? filePath : filePath.substring(0, extenPosi)); } if (extenPosi == -1) { return filePath.substring(filePosi + 1); } return (filePosi < extenPosi ? filePath.substring(filePosi + 1, extenPosi) : filePath.substring(filePosi + 1)); } }