Java File Name Get getFileName(final String p)

Here you can find the source of getFileName(final String p)

Description

get File Name

License

Open Source License

Declaration

public static String getFileName(final String p) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static String getFileName(final String p) {
        return getFileName(new File(p));
    }//from   w ww .  ja  va 2 s. c  o  m

    public static String getFileName(File p) {
        String name = p.getName();
        int firstIndex = name.indexOf(".");
        if (firstIndex != -1) {
            return name.substring(0, firstIndex);
        } else {
            return name;
        }
    }
}

Related

  1. getFileName(File path)
  2. getFileName(final File file)
  3. getFilename(final File file)
  4. getFileName(final File file)
  5. getFilename(final String filenamePath)
  6. getFilename(final String pPath)
  7. getFileName(final String subdirectory)
  8. getFilename(Locale locale, String fileName, String fileType)
  9. getFileName(String absolutePath)