Implement the getFileTree method, which must create a list of all of the files, including nested files. Use a queue. Don't use recursion. Return a list of the paths to all the found files. Don't return paths to directories. The path must be absolute.
Find all the files
You must be signed in to leave a comment
10 March, 11:25
And where is a queue in the correct solution?
8 May 2021, 14:34
It would have been a really nice exercise, if the Validation Conditions weren't wrong. In the Conditions it says: 2.1. Sort them by file name in ascending order. Don't include the path when sorting. 2.2. Rename resultFileAbsolutePath to "allFilesContent.txt" (use the FileUtils.renameFile method and FileUtils.isExist if necessary). If you do it in this order, the Validation won't pass. just do it the other way round - rename the file directly after reading in the programs' input (args) and before sorting/making a set/ whatever. Also checking if the file exists with the FileUtils class (and if, renaming it) is mandatory, so make sure you do this. CG Team, please consider editing the Conditions! Have a look at the help section, everyone is confused. In the "Right Solution" it is done in the inverted order, as well. Really nice task, apart from that.
11 June 2021, 13:02
I believe they changed the conditions because now there isn't a 2.1. and 2.2 condition anymore.
2 May 2021, 08:43
Queue<String> queue = new LinkedList();. First put the root in a queue. while(!queue.isEmpty) Pop the file from the queue and do listFiles().If the file isDirectory() add the full(absolute) path of the file to the queue. if not add the full path of the file to the list. That's it.
23 April 2019, 15:20
How to solve this task without recursion?
20 July 2020, 21:20
Use a queue