Java File Name Extract extractFileName(final String filePath)

Here you can find the source of extractFileName(final String filePath)

Description

extract File Name

License

Open Source License

Declaration

public static String extractFileName(final String filePath) 

Method Source Code

//package com.java2s;
/*/*w  ww. j  ava 2  s. co m*/
 License:
    
 blueprint-sdk is licensed under the terms of Eclipse Public License(EPL) v1.0
 (http://www.eclipse.org/legal/epl-v10.html)
    
    
 Distribution:
    
 Repository - https://github.com/lempel/blueprint-sdk.git
 Blog - http://lempel.egloos.com
 */

public class Main {
    private static final String fileSeparator = System.getProperty("file.separator");

    public static String extractFileName(final String filePath) {
        String result;
        int pos = filePath.lastIndexOf(fileSeparator);
        if (pos < 0) {
            result = filePath;
        } else {
            result = filePath.substring(pos + 1, filePath.length());
        }
        return result;
    }
}

Related

  1. extractFileName(StackTraceElement aFrame)
  2. extractFileName(String file)
  3. extractFileName(String fileName)
  4. extractFileName(String filePathName)