Maybe something like this will work.... It just recursively descends from
the root passed to parseAll, processing each .txt file it finds.
// Parameter is just the file path of the parent directory.
public void parseAll(String sParentDir) throws Exception {
indexTree(new File(sParentDir));
}
private void indexTree(File file) throws Exception {
if (file.canRead()) {
if (file.isDirectory()) {
String[] files = file.list();
if (files != null) {
for (int idx = 0; idx < files.length; idx++) {
indexTree(new File(file, files[idx]));
}
}
} else {
if (file.getName().toLowerCase().indexOf(".txt") == -1)
return;
try {
index your file here.
} catch (Exception e) {
handle error here.
}
}
}
Erick