Recursively find all text files in directory

前端 未结 3 604
离开以前
离开以前 2020-12-10 21:31

I am trying to get the names of all of the text files in a directory. If the directory has subdirectories then I also want to get any text files in those as well. I am not s

3条回答
  •  囚心锁ツ
    2020-12-10 22:17

    The answer is in the tags of your question. Use recursion. Recursion consists in having a method call itself.

    In this case, the method should print all the text files directly under a given directory, and call itself for every subdirectory of the directory.

提交回复
热议问题