-1
I’m doing a work for the college on how to go through directories with java recursive 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 subfolders as well. Thank you.
The above method already does what you said. This question makes no sense. Also, please avoid creating multiple questions for the same problem. If the answer to the first question did not resolve, improve the question by editing it and adding relevant information. You can also add comments to the answers by telling them why they don’t solve the problem.
– utluiz
This question already has an answer here http://answall.com/questions/101904/display-direct%C3%B3rios-in-tree format and also here http://answall.com/questions/101772/recursiva-java-para-ver-pastas-e-subpastas
– utluiz