Java File Name Get getFileName(String s)

Here you can find the source of getFileName(String s)

Description

get File Name

License

Open Source License

Declaration

public static String getFileName(String s) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {

    public static String getFileName(String s) {
        int index = s.lastIndexOf("/");
        String name = null;//  ww  w  .j  a v  a 2s  .co  m
        if (index > -1) {
            name = s.substring(index + 1);
        } else {
            index = s.lastIndexOf(File.separator);
            if (index > 0) {
                name = s.substring(index + 1);
            }
        }
        return name;
    }
}

Related

  1. getFileName(String path)
  2. getFileName(String path)
  3. getFilename(String path)
  4. getFileName(String s)
  5. getFileName(String s)
  6. getFileName(String template, String className, String packageName)
  7. getFileName(String url, String basePath)
  8. getFileNameAndExt(String s)
  9. getFileNameArrayFromDirectory(String directoryLocation)