Java File Name Get getFileName(String folder, final String path)

Here you can find the source of getFileName(String folder, final String path)

Description

get File Name

License

Open Source License

Declaration

public static String getFileName(String folder, final String path) 

Method Source Code


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

import java.io.File;

import java.io.FilenameFilter;

public class Main {
    public static String getFileName(String folder, final String path) {
        File dir = new File(folder);
        String[] list = dir.list(new FilenameFilter() {

            @Override/* www .ja  va 2s .  co  m*/
            public boolean accept(File dir, String name) {
                return name.contains(path);
            }
        });

        if (list.length == 0) {
            return folder + File.separator + path;
        } else {
            return folder + File.separator + path + "(" + list.length + ")";
        }
    }
}

Related

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