Question : how to get all the names of the files in a folder in java?
Answered by : busy-bug-pgzs7emzx5o9
List<String> results = new ArrayList<String>();
File[] files = new File("/path/to/the/directory").listFiles();
//If this pathname does not denote a directory, then listFiles() returns null.
for (File file : files) { if (file.isFile()) { results.add(file.getName()); }
}
Source : https://stackoverflow.com/questions/5694385/getting-the-filenames-of-all-files-in-a-folder | Last Update : Fri, 19 Jun 20