I'm trying to write some XML lines in a XML file. However, I can only do it if the file doesn't exist, because if it exists I'll overwrite the information.
Here's my code:
public void writeToXMLSimulation() throws IOException {
File f = new File("Simulation_" + pt.ipp.isep.gecad.masgrip.MASGriP_GUI.getContainerNameTxt().getText() + "_Details.xml");
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
XMLWriter xmlWriter = null;
if (!f.exists()) {
try {
xmlWriter = new XMLWriter(new OutputStreamWriter(
new FileOutputStream(f), "UTF8"),
format);
xmlWriter.write(configs.XMLwriterDOM4J.createXMLDocumentForSimulations(jLabelAL, jTextFieldAL, id));
} finally {
if (xmlWriter != null) {
xmlWriter.flush();
xmlWriter.close();
}
}
} else {
try {
//I NEED SOMETHING HERE TO GET ME TO THE LAST LINE OF FILE
xmlWriter.write(
configs.XMLwriterDOM4J.createXMLDocumentForSimulations(
jLabelAL, jTextFieldAL, id));
} finally {
if (xmlWriter != null) {
xmlWriter.flush();
xmlWriter.close();
}
}
}
}
What can I do, to make my code write after the last line? (without overwritting)
Thanks