Here you can find the source of getFiles(String path)
public static final List<File> getFiles(String path)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { /**//ww w . j a v a2 s .com * Returns a single file object if the argument is a path to a specific file, * or a list of directory files, if the argument is a path to a folder. */ public static final List<File> getFiles(String path) { File file = new File(path); List<File> list = new ArrayList<File>(); if (file.exists()) { if (file.isFile()) { list.add(file); } else if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { File f = files[i]; if (f.isFile()) { list.add(f); } } } } } return list; } }