Java File Name Get getFileName(String completePath)

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

Description

Gets the fileName from the complete path

License

Open Source License

Parameter

Parameter Description
completePath Description of the Parameter

Return

The fileName value

Declaration

public static String getFileName(String completePath) 

Method Source Code

//package com.java2s;
/*//from ww  w .j  a v  a2 s.c  o m
 * Copyright (c) Fiorano Software Pte. Ltd. and affiliates. All rights reserved. http://www.fiorano.com
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

import java.io.*;

public class Main {
    /**
     * Gets the fileName from the complete path
     *
     * @param completePath Description of the Parameter
     * @return The fileName value
     */
    public static String getFileName(String completePath) {
        if (completePath == null)
            return null;

        return completePath.substring(completePath.lastIndexOf(File.separator) + 1, completePath.length());
    }
}

Related

  1. getFileName(final String p)
  2. getFilename(final String pPath)
  3. getFileName(final String subdirectory)
  4. getFilename(Locale locale, String fileName, String fileType)
  5. getFileName(String absolutePath)
  6. getFileName(String dir, String name)
  7. getFileName(String f)
  8. getFileName(String fileName)
  9. getFileName(String filePath)