Java Directory to File List getAllFiles(String directory)

Here you can find the source of getAllFiles(String directory)

Description

Get all file (non-recursively) from a directory.

License

Open Source License

Parameter

Parameter Description
directory The directory to read.

Return

A list of filenames (without path) in the input directory.

Declaration

public static String[] getAllFiles(String directory) 

Method Source Code

//package com.java2s;
/*===============================================================================
 * Copyright (c) 2010-2015 University of Massachusetts.  All Rights Reserved.
 *
 * Use of the RankLib package is subject to the terms of the software license set 
 * forth in the LICENSE file included with this software, and also available at
 * http://people.cs.umass.edu/~vdang/ranklib_license.html
 *===============================================================================
 *///from  w ww .ja  v a 2  s.co  m

import java.io.*;

public class Main {
    /**
     * Get all file (non-recursively) from a directory.
     * @param directory The directory to read.
     * @return A list of filenames (without path) in the input directory.
     */
    public static String[] getAllFiles(String directory) {
        File dir = new File(directory);
        String[] fns = dir.list();
        return fns;
    }
}

Related

  1. getAllFiles(File sourceDirectory, List fileList)
  2. getAllFiles(final String path, final String suffix, boolean recurse)
  3. getAllFiles(String dir)
  4. getAllFiles(String dir, String extension)
  5. getAllFiles(String dir, String filePattern)
  6. getAllFiles(String directory)
  7. getAllFiles(String dirPath)
  8. getAllFiles(String folderPath)
  9. getAllFiles(String path)