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

StringgetFileNamePart(final File file)
Returns file name without extension.
return getFileNamePart(file.getName());
String[]getFilenameParts(File file)
get Filename Parts
if (file == null) {
    return null;
return getFilenameParts(file.getName());
SetgetFileNames(byte[] zipFile)
Gets the file names in a zip file
Set<String> fileNames = new HashSet<>();
ByteArrayInputStream inputStream = new ByteArrayInputStream(zipFile);
ZipInputStream zis = new ZipInputStream(inputStream);
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
    fileNames.add(entry.getName());
return fileNames;
...
voidgetFileNames(File path, Vector result)
get File Names
File[] files = path.listFiles(new FileFilter() {
    public boolean accept(File pathname) {
        return pathname.isDirectory() || pathname.toString().toLowerCase().endsWith(".java")
                || pathname.toString().toLowerCase().endsWith(".r")
                || pathname.toString().toLowerCase().endsWith("build.xml");
});
if (files == null)
...
CollectiongetFileNames(File zipFile, Pattern pattern)
searches for all filenames that match the given regex-pattern
ZipFile theZipFile;
try {
    theZipFile = new ZipFile(zipFile);
} catch (ZipException e) {
    throw new Error(e);
} catch (IOException e) {
    throw new Error(e);
return getFileNames(theZipFile, pattern);
String[]getFilenames(File[] files)
get Filenames
ArrayList<String> result = new ArrayList<String>();
for (File afile : files) {
    result.add(afile.getAbsolutePath());
return result.toArray(new String[0]);
String[]getFileNames(File[] files)
get File Names
String[] fileNames = new String[files.length];
for (int i = 0; i < fileNames.length; i++) {
    fileNames[i] = files[i].getName();
return fileNames;
ListgetFileNames(final String path, final String regex)
get File Names
List<String> names = new ArrayList<String>();
File dir = new File(path);
String[] files = dir.list();
for (String file : files) {
    if (file.matches(regex)) {
        names.add(file);
return names;
String[]getFileNames(final String pDataDir, final String pFilter)
Returns files from the data dir based on the max allowed.
return getFileNames(pDataDir, pFilter, false);
String[]getFilenames(String dir, FilenameFilter filter)
get Filenames
File[] files;
if (filter == null) {
    files = (new File(dir)).listFiles();
} else {
    files = (new File(dir)).listFiles(filter);
String[] filenames = new String[files.length];
for (int i = 0; i < files.length; i++) {
...