Element newPlay = new Element("play");
saveNewPlay(newPlay, cPlay, args);
newPlayer.addContent(newPlay);
rootNode.addContent(newPlayer);
}
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat());
xmlOutput.output(document, new FileWriter(gameFile));
System.out.println("Games file updated!");
} catch (IOException e) {
System.out.println(e.getMessage());
} catch (JDOMException jdome) {
System.out.println(jdome.getMessage());
}
} else {
System.out.println("Games file doesn't exist!");
System.out.println("Create new games file");
try {
Element plays = new Element("plays");
Document doc = new Document(plays);
Element newPlayer = new Element("player");
newPlayer.setAttribute(new Attribute("id", cPlay.getOwner()));
Element newPlay = new Element("play");
saveNewPlay(newPlay, cPlay, args);
newPlayer.addContent(newPlay);
doc.getRootElement().addContent(newPlayer);
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat());
xmlOutput.output(doc, new FileWriter(gameFile));
System.out.println("Game file Created & updated!");
} catch (IOException e) {
System.out.println(e.getMessage());
}