Here you can find the source of getFileName(String folder, final String path)
public static String getFileName(String folder, final String path)
//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 + ")"; } } }