1List<String> results = new ArrayList<String>();
2
3
4File[] files = new File("/path/to/the/directory").listFiles();
5//If this pathname does not denote a directory, then listFiles() returns null.
6
7for (File file : files) {
8 if (file.isFile()) {
9 results.add(file.getName());
10 }
11}
1File folder = new File("/Users/you/folder/");
2File[] listOfFiles = folder.listFiles();
3
4for (File file : listOfFiles) {
5 if (file.isFile()) {
6 System.out.println(file.getName());
7 }
8}
9