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; public class Main { public static String getFileNameWithoutExtension(File file) { String filename = file.getName().trim(); if (filename.length() == 0) return ""; if (filename.charAt(filename.length() - 1) == '.') filename = filename.substring(0, filename.length() - 1); int lastPointIndex = filename.lastIndexOf('.'); if (lastPointIndex < 0) return filename; else if (lastPointIndex == 0) return ""; else// w w w.j a v a 2 s . co m return filename.substring(0, lastPointIndex); } }