Java File Name Get getFileNamesFromDir(File rootDir, String indexName)

Here you can find the source of getFileNamesFromDir(File rootDir, String indexName)

Description

Returns the list of file names in the specified directory.

License

Apache License

Parameter

Parameter Description
rootDir the root directory.
indexName the name of the subdirectory.

Return

the array of the names of the files.

Declaration

public static String[] getFileNamesFromDir(File rootDir, String indexName) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    /**/* www  .  ja va2  s .  c  o m*/
     * Returns the list of file names in the specified directory.
     *
     * @param rootDir       the root directory.
     * @param indexName     the name of the subdirectory.
     * @return              the array of the names of the files.
     */
    public static String[] getFileNamesFromDir(File rootDir, String indexName) {
        File indexDir = new File(rootDir.getAbsoluteFile(), indexName);
        assert indexDir.exists();

        String[] fileNames = indexDir.list();
        assert fileNames.length > 0;

        return fileNames;
    }
}

Related

  1. getFileNames(String directory, String file)
  2. getFileNames(String dirPath)
  3. getFilenames(String filenames)
  4. getFileNames(String path, boolean withFullPath)
  5. getFileNames_STR(String path)
  6. getFileNamesInJar(File source, String folder, String extension)
  7. getFileNamesOld(File zipFile)
  8. getFileNamesRecursive(final String pDataDir, final FilenameFilter pFilter, final int pMaxFiles)
  9. getFileNameStartingWith(String directory, String prefix)