Here you can find the source of basename(String filename)
public static String basename(String filename)
//package com.java2s; public class Main { public static String basename(String filename) { String result = filename; int p = result.lastIndexOf('/'); if (p >= 0) { result = result.substring(p + 1); }//from ww w. j a v a 2 s . c om p = result.lastIndexOf('.'); if (p >= 0) { result = result.substring(0, p); } return result; } public static String substring(StringBuffer buf, int start, int lim) { int len = lim - start; char[] result = new char[len]; buf.getChars(start, lim, result, 0); return String.valueOf(result); } }