Here you can find the source of getFileNameOnly(String fileName)
public static String getFileNameOnly(String fileName)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.io.*; public class Main { public static String getFileNameOnly(String fileName) { int index = -1; String auxString = fileName, returnedValue = null; index = fileName.lastIndexOf(File.separator); if (index == -1) index = fileName.lastIndexOf('/'); if (index != -1) auxString = fileName.substring(index + 1); // Remove extension index = auxString.lastIndexOf('.'); if (index != -1) auxString = auxString.substring(0, index); returnedValue = auxString;// w w w . j a va 2 s. com return returnedValue; } }