Java File Base Name Get basename(String path)

Here you can find the source of basename(String path)

Description

basename

License

Open Source License

Declaration

public static String basename(String path) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String basename(String path) {
        if (path == null)
            return "";

        path = path.replaceAll("/+$", "");
        int i = path.lastIndexOf('/');

        return (path.isEmpty()) ? "/" : (i == -1) ? path : path
                .substring(i + 1);/*from   w w w .  ja va 2 s  .com*/
    }
}

Related

  1. baseName(String filename)
  2. baseName(String fn)
  3. baseName(String name)
  4. basename(String name, String split)
  5. basename(String path)
  6. basename(String path)
  7. basename(String path)
  8. basename(String path)
  9. baseName(String path)