Walk a directory tree recursively
It's simpler to just return the result immediately then need another method.

Also the caller is probably going to need them as File objects eventually so lets just return them as those.

Then there are 2 options, just return a List and use addAll each recursion step:

public List&lt;File&gt; walkDir(File pathname) {
    if(pathname.isDirectory()) {
        List&lt;File&gt; files = new ArrayList();
        files.add(pathname);
        for(File f : pathname.listFiles()) {
            filed.addAll(walkDir(f));
        }
        return files;
    }else{
        return Collections.singletonList(pathname);
    }
}


Or use a private recursive method where you pass in a accumulator List:

private void walkDirRecurse(File pathname, List&lt;File&gt; files) {
    if(pathname.isDirectory()) {
        for(File f : pathname.listFiles()) {
            files.add(f);
            walkDirRecurse(f, files);
        }
    }
}