Here you can find the source of getFileNameWithoutExt(String file)
public static String getFileNameWithoutExt(String file)
//package com.java2s; import java.io.File; public class Main { public static String getFileNameWithoutExt(String file) { return file.substring(getSeparatorIndex(file), getDotIndex(file)); }//w w w . ja v a 2s .co m public static int getSeparatorIndex(String file) { int sepIndex = file.lastIndexOf(File.separator); if (sepIndex != -1) return sepIndex + 1; else return 0; } public static int getDotIndex(String file) { int dotIndex = file.lastIndexOf("."); if (dotIndex != -1) return dotIndex; else return file.length(); } }