Java tutorial
//package com.java2s; import java.io.File; public class Main { /** * Returns the filename without path and without extension. * * @param fileName * @return the file name without extension and path */ public static String basename(final String fileName) { int dot = fileName.lastIndexOf('.'); int sep = fileName.lastIndexOf(File.separatorChar); if (sep == -1) { sep = fileName.lastIndexOf('\\'); } if (dot == -1) { dot = fileName.length(); } return fileName.substring(sep + 1, dot); } }