The Problem I need to write a simple software that, giving certain constraints, appends to a list a series of files. The user could choose between
My iterative solution:
ArrayDeque stack = new ArrayDeque();
stack.push(new File(""));
int n = 0;
while(!stack.isEmpty()){
n++;
File file = stack.pop();
System.err.println(file);
File[] files = file.listFiles();
for(File f: files){
if(f.isHidden()) continue;
if(f.isDirectory()){
stack.push(f);
continue;
}
n++;
System.out.println(f);
}
}
System.out.println(n);