public void writeFile(ArrayList<DccLocoAddress> consistList,String fileName) throws IOException {
  Element root=new Element("consist-roster-config");
  Document doc=newDocument(root,dtdLocation + "consist-roster-config.dtd");
  Map<String,String> m=new HashMap<String,String>();
  m.put("type","text/xsl");
  m.put("href",xsltLocation + "consistRoster.xsl");
  ProcessingInstruction p=new ProcessingInstruction("xml-stylesheet",m);
  doc.addContent(0,p);
  Element roster=new Element("roster");
  for (int i=0; i < consistList.size(); i++) {
    Consist newConsist=consistMan.getConsist(consistList.get(i));
    roster.addContent(consistToXml(newConsist));
  }
  root.addContent(roster);
  try {
    if (!checkFile(fileName)) {
      File file=new File(fileName);
      File parentDir=file.getParentFile();
      if (!parentDir.exists()) {
        if (!parentDir.mkdir()) {
          throw (new IOException());
        }
      }
      if (!file.createNewFile()) {
        throw (new IOException());
      }
    }
    writeXML(findFile(fileName),doc);
  }
 catch (  IOException ioe) {
    log.error("IO Exception " + ioe);
    throw (ioe);
  }
}

public void writeFile ( ArrayList < DccLocoAddress > consistList , String fileName ) throws IOException { Element root = new Element ( "consist-roster-config" ) ; Document doc = newDocument ( root , dtdLocation + "consist-roster-config.dtd" ) ; Map < String , String > m = new HashMap < String , String > ( ) ; m . put ( "type" , "text/xsl" ) ; m . put ( "href" , xsltLocation + "consistRoster.xsl" ) ; ProcessingInstruction p = new ProcessingInstruction ( "xml-stylesheet" , m ) ; doc . addContent ( 0 , p ) ; Element roster = new Element ( "roster" ) ; for ( int i = 0 ; i < consistList . size ( ) ; i ++ ) { Consist newConsist = consistMan . getConsist ( consistList . get ( i ) ) ; roster . addContent ( consistToXml ( newConsist ) ) ; } root . addContent ( roster ) ; try { if ( ! checkFile ( fileName ) ) { File file = new File ( fileName ) ; File parentDir = file . getParentFile ( ) ; if ( ! parentDir . exists ( ) ) { if ( ! parentDir . mkdir ( ) ) { throw ( new IOException ( ) ) ; } } if ( ! file . createNewFile ( ) ) { throw ( new IOException ( ) ) ; } } writeXML ( findFile ( fileName ) , doc ) ; } catch ( IOException ioe ) { log . error ( "IO Exception " + ioe ) ; throw ( ioe ) ; } }
write all consists to a file .
