Here you can find the source of getFileNameWithoutExtension(File file)
public static String getFileNameWithoutExtension(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.Locale; public class Main { public static String getFileNameWithoutExtension(File file) { if (file == null) return null; String fileExt = getFileExtension(file); String fileName = file.getName(); return fileName.substring(0, fileName.length() - fileExt.length() - 1); }//from w w w. j a v a2s .c o m public static String getFileExtension(File file) { if (file == null) return null; String fileName = file.getName(); String fileExt = null; int i = fileName.lastIndexOf("."); if (i > 0 && i < fileName.length() - 1) { fileExt = fileName.substring(i + 1).toLowerCase(Locale.ENGLISH); } return fileExt; } }