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

StringgetFileNameWithoutExtension(String fullFilename)
Returns file name without extension.
final String fileName = new File(fullFilename).getName();
final int dotIndex = fileName.lastIndexOf('.');
final String fileNameWithoutExtension;
if (dotIndex == -1) {
    fileNameWithoutExtension = fileName;
} else {
    fileNameWithoutExtension = fileName.substring(0, dotIndex);
return fileNameWithoutExtension;
StringgetFileNameWithoutExtensionFromPath(String s)
get File Name Without Extension From Path
s = s.replace(File.separatorChar, '/');
s = getLastPortion(s, '/');
int k = s.lastIndexOf('.');
if (k != -1) {
    return s.substring(0, k);
} else
    return s;
StringgetFilenameWithoutExtention(File file)
get Filename Without Extention
return stripExtension(file.getName());
StringgetFileNameWithoutFilePath(File f)
Returns the file name of a file, without the path.
return f.getName();
StringgetFilenameWithoutPath(String path)
Takes a filename with path and returns just the filename.
File f = new File(path);
return f.getName();
StringgetFileNameWithPath(String path, String fileNameWithoutFullPath)
get File Name With Path
return path + File.separator + fileNameWithoutFullPath;