Here you can find the source of getFileName(String fileName)
public static final String getFileName(String fileName)
//package com.java2s; import java.io.File; public class Main { public static final String getFileName(String fileName) { if (isEmpty(fileName)) { return null; }//from www . j a v a2s.co m return fileName.substring(0, fileName.lastIndexOf(".")); } public static String getFileName(File file) { if (file == null) { return null; } return getFileName(file.getName()); } public static final boolean isEmpty(String input) { if (input == null || "".equals(input)) return true; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { return false; } } return true; } public static boolean isEmpty(Object object) { return toString(object).isEmpty(); } public static <T> boolean isEmpty(T[] array) { return (array == null) || (array.length == 0); } public static String toString(Object object) { return (object == null) ? "" : object.toString(); } }