/** Rebuild the Roster index and store it. */ public void reindex() { Roster roster = new Roster(); for (String fileName : Roster.getAllFileNames()) { // Read file try { Element loco = (new LocoFile()) .rootFromName(LocoFile.getFileLocation() + fileName) .getChild("locomotive"); if (loco != null) { RosterEntry re = new RosterEntry(loco); re.setFileName(fileName); roster.addEntry(re); } } catch (JDOMException | IOException ex) { log.error("Exception while loading loco XML file: {} execption: {}", fileName, ex); } } this.makeBackupFile(this.getRosterIndexPath()); try { roster.writeFile(this.getRosterIndexPath()); } catch (IOException ex) { log.error("Exception while writing the new roster file, may not be complete: {}", ex); } this.reloadRosterFile(); log.info("Roster rebuilt, stored in {}", this.getRosterIndexPath()); }