Skip to content

Instantly share code, notes, and snippets.

@anderson-martins
Created August 16, 2012 17:28
Show Gist options
  • Save anderson-martins/3371883 to your computer and use it in GitHub Desktop.
Save anderson-martins/3371883 to your computer and use it in GitHub Desktop.
Lista arquivos, pastas e subpastas de um diretorio
public static java.util.List<FileItem> listDirectoryAppend(File dir, java.util.List<FileItem> lista) {
if (dir.isDirectory()) {
String[] filhos = dir.list();
for (int i = 0; i < filhos.length; i++) {
File nome = new File(dir, filhos[i]);
if (nome.isFile()) {
if (nome.getName().toUpperCase().endsWith(".GBK")) {
lista.add(new FileItem(nome));
}
} else if (nome.isDirectory()) {
listDirectoryAppend(nome, lista);
}
}
} else {
lista.add(new FileItem(dir));
}
return lista;
}
@megalexandre
Copy link

esta bacana, mas esse java.util.List lista importe deveria ser omitido.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment