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
PARTY, thank you for advice. I transformed a little bit your code, that's what I've got
private ArrayList displayDirectory(File node){
ArrayList FileList = new ArrayList();
ArrayList directories = new ArrayList();
if (node.isDirectory())
directories.add(node);
// Iterate over the directory list
Iterator it = directories.iterator();
for (int i = 0 ; i < directories.size();i++){
File dir = directories.get(i);
// get childs
String[] subNode = dir.list();
for(int j = 0 ; j < subNode.length;j++){
File F = new File( directories.get(i).getAbsolutePath(), subNode[j]);
// display current child name
// System.out.println(F.getAbsoluteFile());
// if directory : add current child to the list of dir to process
if (F.isDirectory()) directories.add(F);
else FileList.add(F);
}
}
return FileList;
}