Here you can find the source of fileName(String name)
public static String fileName(String name)
//package com.java2s; /*/*from w ww . j av a 2 s . c o m*/ * Copyright (C) 2015 University of Oregon * * You may distribute under the terms of either the GNU General Public * License or the Apache License, as specified in the LICENSE file. * * For more information, see the LICENSE file. */ public class Main { /** Return filename sans extension. */ //---------------------------------------------------------------- public static String fileName(String name) { String fname = pathName(name); int index = name.indexOf("."); if (index > 0) fname = fname.substring(0, index); return fname; } /** Return the last directory or filenname in a path. */ //---------------------------------------------------------------- public static String pathName(String path) { int i = path.lastIndexOf("/"); int j = path.lastIndexOf("\\"); int k = i > j ? i : j; if (k < 0) return path; return path.substring(k + 1, path.length()); } }