Android Path to File Name Convert getFilename(String path)

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

Description

get Filename

Declaration

public static String getFilename(String path) 

Method Source Code

//package com.java2s;

public class Main {
    private static final String FOLDER_SEPARATOR = "/";

    public static String getFilename(String path) {
        if (path == null) {
            return null;
        }//  w w  w .  java 2  s . c  om
        int separatorIndex = path.lastIndexOf(FOLDER_SEPARATOR);
        return (separatorIndex != -1 ? path.substring(separatorIndex + 1)
                : path);
    }
}

Related

  1. getFileNameIndexFromPath(String filePathName)
  2. getShortFileName(String fullFileName)
  3. extractFolderOrFilename(String path)
  4. getFileName(String path)