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(Class cls, String ext)
get File Name
return new File(CODEGENDIR, cls.getSimpleName() + ext).getAbsolutePath();
StringgetFileName(File element)
get File Name
String name = element.getName();
return name.length() == 0 ? element.getPath() : name;
StringgetFileName(File f)
get File Name
String ext = null;
String s = f.getName();
int i = s.lastIndexOf(File.pathSeparatorChar);
if (i > 0 && i < s.length() - 1) {
    ext = s.substring(i + 1).toLowerCase();
return ext;
StringgetFileName(File f)
Return the file name without path or extension.
if (f == null)
    return null;
String fn = f.getName();
if (fn.length() <= 0 || fn.equals(".") || fn.equals(".."))
    return fn;
int p = fn.lastIndexOf('.');
if (p < 0)
    return fn;
...
StringgetFileName(File f)
get File Name
int pos = f.getName().lastIndexOf(".");
String fileName = f.getName().substring(0, pos);
return fileName;
StringgetFileName(File file)
get File Name
String[] nameArr = file.getName().split("\\.");
StringBuilder name = new StringBuilder();
for (int i = 0; i < nameArr.length - 1; i++) {
    name.append(nameArr[i]);
    if (i != nameArr.length - 2) {
        name.append(".");
return name.toString();
StringgetFileName(File file)
Returns file name.
return (file != null) ? file.getName() : "";
StringgetFileName(File file)
Returns the name of the given file.
if (file == null) {
    return null;
String name = file.getName();
int lastIndexOfDot = name.lastIndexOf('.');
if (lastIndexOfDot != -1) {
    return name.substring(0, lastIndexOfDot);
return name;
StringgetFileName(File file)
get File Name
return file.getName();
StringgetFilename(File file)
Get file name from the specified File object.
if (file != null) {
    String path = file.getPath();
    int len = path.length();
    int num2 = len;
    while (--num2 >= 0) {
        char ch1 = path.charAt(num2);
        if (ch1 == File.separatorChar)
            return path.substring(num2 + 1, len);
...