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

String[]getFileNameArrayFromDirectory(String directoryLocation)
get File Name Array From Directory
String[] children = null;
try {
    File dir = new File(directoryLocation);
    children = dir.list();
    if (children == null) {
        children = new String[0];
} catch (Exception e) {
...
FilenameFiltergetFileNameFilter(final String endsWith)
Erstellt einen Dateienamenfilter fuer Dateiendungen
return new FilenameFilter() {
    public boolean accept(File directory, String fileName) {
        if (endsWith == null)
            return true;
        return fileName.toLowerCase().endsWith(endsWith.toLowerCase());
};
FilenameFiltergetFilenameFilter(final String extension)
get Filename Filter
return new FilenameFilter() {
    @Override
    public boolean accept(File file, String name) {
        return file.isFile() && name.endsWith(extension);
};
FilenameFiltergetFilenameFilter(final String pFilter, final boolean pExclude)
Returns the file filter object.
return getFilenameFilter(pFilter, pExclude, false);
StringgetFilenameForClassName(String className)
get Filename For Class Name
return className.replace('.', File.separatorChar) + JavaFileObject.Kind.CLASS.extension;
StringgetFileNameFromCanonical(String file)
get File Name From Canonical
if (file == null)
    return null;
int n = file.lastIndexOf(".");
if (n != -1)
    file = file.substring(0, n);
n = file.lastIndexOf(File.separator);
if (n != -1)
    file = file.substring(n + 1, file.length());
...
StringgetFileNameFromFilePath(String filepath)
get the filename from filepath eg D:\\R4.2chm --> R4.2chm
boolean c = filepath.lastIndexOf("/") == -1 ? false : true;
if (c) {
    filepath = filepath.substring(filepath.lastIndexOf("/") + 1);
} else {
    filepath = filepath.substring(filepath.lastIndexOf(File.separator) + 1);
return filepath;
StringgetFileNameFromFilePath(String filePath)
get File Name From File Path
String fileName = filePath.substring(filePath.lastIndexOf(File.separator) + File.separator.length());
return fileName;
StringgetFileNameFromFullPath(String fullPath)
Extracts the filename from the full file path.
return new File(fullPath).getName();
StringgetFileNameFromZipEntry(ZipEntry entry)
get File Name From Zip Entry
String fileName = entry.getName();
int idx;
if ((idx = fileName.lastIndexOf("/")) > -1 || (idx = fileName.lastIndexOf(File.separator)) > -1) {
    fileName = fileName.substring(idx + 1);
return fileName;