The question is rather simple, but my brain boils :(((
I know, that i should recursive function, but I can’t organize it properely,
because I’m limited by the types(it’s a requirment)
public String[] getFiles(String initialDir) {}
First in my code I get the list of files and directories of initialDir
then i go through the elements and look up for directories with the help of
.isDirectory()
and then I try to organize recursion, something like:
String [] buf = getFiles(Filelist[i].toString());
and here come troubles.
The main problem is, determining the size of obtained data and allocating
the necessary array of String [] type and further writing all recursion results
and first-call results to the resulting array of String [] type.
It really annoys me, so i need a fresh look from a side (maybe someone will help with
code in the function).
Thanks to all!
You can use a list in the body of your method then convert it to an array: