Skip to content

Instantly share code, notes, and snippets.

@rodrigobravo
Forked from anderson-martins/listaDiretorio.java
Created March 14, 2017 23:10
Show Gist options
  • Select an option

  • Save rodrigobravo/4813cae7dff5d2fa18b029e3c7d1ba73 to your computer and use it in GitHub Desktop.

Select an option

Save rodrigobravo/4813cae7dff5d2fa18b029e3c7d1ba73 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment