How To Get All The Names Of The Files In

[Solved] How To Get All The Names Of The Files In | Java - Code Explorer | yomemimo.com
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

Answers related to how to get all the names of the files in a folder in java?

Code Explorer Popular Question For Java