I'm doing a job for college on how to go through directories with recursive in java and so far I have this code here:
package Control;
import java.awt.Desktop;
import java.io.*;
public class PercorreDir {
private String pastas = "";
StringBuffer buffer = new StringBuffer();
public String percorre(String caminho, String espaço){
File documentos = new File(caminho);
for( File files : documentos.listFiles()){
if(files.isDirectory()) {
buffer.append(files + espaço);
percorre(caminho, espaço);
}
}
return pastas;
}
}
What I want to know is how do I go through the sub-folders as well. Thank you.