Java File Name Get getFileName(String originPath)

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

Description

Get the file name, given a complete path.

License

Open Source License

Parameter

Parameter Description
originPath The complete path.

Declaration

public static String getFileName(String originPath) 

Method Source Code


//package com.java2s;
import java.io.File;

public class Main {
    /**//w  ww .  ja va  2  s .  co  m
     * Get the file name, given a complete path.
     * @param originPath The complete path.
     * @return
     */
    public static String getFileName(String originPath) {
        String file = "";
        try {
            file = originPath.substring(originPath.lastIndexOf(File.separatorChar) + 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return file;
    }
}

Related

  1. getFileName(String filePath)
  2. getFileName(String folder, final String path)
  3. getFilename(String fullFilename)
  4. getFileName(String localRootDirName, String ending)
  5. getFileName(String name)
  6. getFilename(String path)
  7. getFileName(String path)
  8. getFileName(String path)
  9. getFileName(String path)