So currently I can read and write to an xml file when I'm running the program in eclipse, but when I export it as a .jar the writing does not work any more.
public void addHighscores(String naam, String score){
Document document = null;
Element root = null;
InputStream fis = getClass().getResourceAsStream("Highscores.xml");
SAXBuilder sb = new SAXBuilder();
document = sb.build(fis);
root = document.getRootElement();
fis.close();
Element player = new Element("player");
player.addContent(new Element("name").setText(naam));
player.addContent(new Element("score").setText(score));
root.addContent(player);
document.setContent(root);
FileWriter writer = new FileWriter(path);
XMLOutputter outputter = new XMLOutputter();
outputter.setFormat(Format.getPrettyFormat());
outputter.output(document, writer);
outputter.output(document, System.out);
writer.close();}
That's the code for the writer. The xml file is saved in the same folder as the code, I don't understand why it can read but not write. Thanks in advance