List of usage examples for org.jdom2 Document removeContent
@Override public Content removeContent(int index)
From source file:org.isima.carsharing.launcher.Launcher.java
public static void addConfigComment(SettingsDelegate settingsDelegate, File out) { try {/*ww w.jav a 2 s . c o m*/ SAXBuilder builder = new SAXBuilder(); Document doc = (Document) builder.build(out); Element rootNode = doc.getRootElement(); Element rootNodeCopy = rootNode.clone(); doc.removeContent(rootNode); rootNodeCopy.detach(); Comment comment = new Comment(settingsDelegate.usedConfigsToXMLComment()); doc.addContent(comment); doc.addContent(rootNodeCopy); XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); xmlOutput.output(doc, new FileWriter(out)); } catch (JDOMException | IOException ex) { Logger.getLogger(Launcher.class.getName()).log(Level.SEVERE, null, ex); } }