I've got code as below:
class ListPageXMLFiles implements FileFilter {
@Override
public boolean accept(File pathname) {
DebugLog.i("ListPageXMLFiles", "pathname is " + pathname);
String regex = ".*page_\\d{2}\\.xml";
if(pathname.getAbsolutePath().matches(regex)) {
return true;
}
return false;
}
}
public void loadPageTrees(String xml_dir_path) {
ListPageXMLFiles filter_xml_files = new ListPageXMLFiles();
File XMLDirectory = new File(xml_dir_path);
for(File _xml_file : XMLDirectory.listFiles(filter_xml_files)) {
loadPageTree(_xml_file);
}
}
The FileFilter
is working nicely, but listFiles()
seems to be listing the files in reverse alphabetical order. Is there some quick way of telling listFile()
to list the files in alphabetical order?
.endsWith(".xml")
instead. – Jin