You need to implement a recursive method that will list all folders within a folder, thus:

mainDir |--dir1 | |--dir11 | |--dir12 | |--dir121 |--dir2 | |--dir23 | |--dir231 |--dir3 

As an argument, you can take only the path to the folder itself, and I just won’t understand how to indent the names.

  • It is necessary - implement! Or with something more specific questions? Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. - Kromster
  • Good afternoon, the problem is described just above, I do not understand how to display the hierarchy, if I may say so. That is, in front of a file that is 2 levels deeper there were 4 spaces, and before that it is 3 - 6. - Stromage
  • one
    In the recursive method, pass the value of the indent (the number of spaces). For subdirectories, pass "current + 4". For the original ( mainDir ) - 0. And judging by the general logic, with zero indent | should be only in three lines ( dir1 , dir2 , dir3 ) - Regent
  • The only thing I can pass to the method is the path to the file, and nothing else. I apologize if it was not clearly expressed when I wrote this about it. - Stromage
  • one
    Where does this condition come from? You can change the method signature? You can not forward the indent as a parameter to a method, but store the current indent as, for example, a static field, but the method parameter is the preferred option. - Regent

0