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) {
        int index = path.lastIndexOf('/');
        if (index == -1) {
            throw new IllegalArgumentException("path does not contain '/'");
        }// w ww . j a v  a 2s  . co m
        return path.substring(index + 1);
    }
}

Related

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