Here you can find the source of getFiles(String dir)
Parameter | Description |
---|---|
dir | a directory |
public static File[] getFiles(String dir)
//package com.java2s; //License from project: BSD License import java.io.File; import java.util.ArrayList; public class Main { /**// w w w.ja v a2s .c o m * Returns the files in the given directory (only normal files, no * subdirectories). * * @param dir a directory * @return files in the directory */ public static File[] getFiles(String dir) { ArrayList<File> files = new ArrayList<File>(); // only return normal files, no subdirectories File[] filesOrDirs = new File(dir).listFiles(); for (File fileOrDir : filesOrDirs) if (fileOrDir.isFile()) files.add(fileOrDir); return files.toArray(new File[files.size()]); } }