Here you can find the source of basename(String path)
Parameter | Description |
---|---|
path | The path to examine |
public static String basename(String path)
//package com.java2s; public class Main { /**//from w w w .j ava 2 s . c o m * Return the filename portion of a path. * @param path The path to examine * @return The filename or empty string if the path is empty or null */ public static String basename(String path) { String filename = path.substring(path.lastIndexOf('/') + 1); if (filename == null || filename.equalsIgnoreCase("")) { filename = ""; } return filename; } }