Java File Name Create fileName(String path)

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

Description

file Name

License

Open Source License

Declaration

public static String fileName(String path) 

Method Source Code

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

public class Main {
    public static String fileName(String path) {
        if (path.endsWith("/")) {
            throw new IllegalArgumentException("path cannot end with a slash");
        }//from   w w w .j  a v  a  2  s  .  c  om

        int indexOfLastSeparator = path.lastIndexOf('/');
        if (indexOfLastSeparator == -1) {
            throw new IllegalArgumentException("path does not contain any slashes");
        }

        return path.substring(indexOfLastSeparator + 1);
    }
}

Related

  1. fileName(String name)
  2. filename(String name)
  3. filename(String name, String ext)
  4. fileName(String path)
  5. fileName(String path)
  6. filename(String prefix, String sep, String index)
  7. FileName(String[] args)
  8. generateFileId(String userlogin)
  9. generateFileName()