Java Utililty Methods File Name Get

List of utility methods to do File Name Get

Description

The list of methods to do File Name Get are organized into topic(s).

Method

StringgetFileName(String folder, final String path)
get File Name
File dir = new File(folder);
String[] list = dir.list(new FilenameFilter() {
    @Override
    public boolean accept(File dir, String name) {
        return name.contains(path);
});
if (list.length == 0) {
...
StringgetFilename(String fullFilename)
Get filename from full path.
int pos = fullFilename.lastIndexOf(File.separatorChar);
return fullFilename.substring(pos + 1);
StringgetFileName(String localRootDirName, String ending)
get File Name
File folder = new File(localRootDirName);
File[] listOfFiles = folder.listFiles();
int i = 0;
for (i = 0; i < listOfFiles.length; i++) {
    if (listOfFiles[i].getName().indexOf(ending) >= 0)
        break;
if (i == listOfFiles.length)
...
StringgetFileName(String name)
get File Name
if (new File(name).exists()) {
    return name;
if (System.getProperty("os.name").contains("Mac")) {
    try {
        String appBundle = (String) Class.forName("com.apple.eio.FileManager")
                .getMethod("getPathToApplicationBundle", (Class[]) null).invoke(null, (Object[]) null);
        if (new File(appBundle + "/Contents/Resources/Java/" + name).exists()) {
...
StringgetFileName(String originPath)
Get the file name, given a complete path.
String file = "";
try {
    file = originPath.substring(originPath.lastIndexOf(File.separatorChar) + 1);
} catch (Exception e) {
    e.printStackTrace();
return file;
StringgetFileName(String path)
get File Name
String filename = path;
if (filename.contains(File.separator)) {
    filename = filename.substring(filename.lastIndexOf(File.separatorChar) + 1);
return filename;
StringgetFilename(String path)
get Filename
int pos = path.lastIndexOf(File.separator);
return path.substring(pos + 1, path.length());
StringgetFileName(String path)
get File Name
int separatorIndex = path.lastIndexOf(File.separator);
return (separatorIndex < 0) ? path : path.substring(separatorIndex + 1, path.length());
StringgetFilename(String path)
get Filename
List<String> list = Splitter.on(File.separator).splitToList(path);
return list.get(list.size() - 1);
StringgetFileName(String path)
Gets the file name.
int mid = path.lastIndexOf(FILE_PATH_SEPARATOR);
return path.substring(mid + 1, path.length());