Program: 171297
Project: 171297
Buggy source:
public static void exportGame(){
  try {
    if (timeLog) {
      timeStart=System.nanoTime();
      System.out.println(timeStart);
    }
    DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder=docFactory.newDocumentBuilder();
    Document doc=docBuilder.newDocument();
    Element game=doc.createElement("String_Node_Str");
    doc.appendChild(game);
    Element informationNode=doc.createElement("String_Node_Str");
    game.appendChild(informationNode);
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",Main.VERSION_NUMBER);
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",String.valueOf(Main.game.minutesPassed));
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",String.valueOf(Main.game.debugMode));
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",String.valueOf(Main.game.imperialMeasurements));
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",Main.game.currentWeather.toString());
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",String.valueOf(Main.game.nextStormTime));
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",String.valueOf(Main.game.weatherTimeRemaining));
    Element dateNode=doc.createElement("String_Node_Str");
    informationNode.appendChild(dateNode);
    CharacterUtils.addAttribute(doc,dateNode,"String_Node_Str",String.valueOf(Main.game.startingDate.getYear()));
    CharacterUtils.addAttribute(doc,dateNode,"String_Node_Str",String.valueOf(Main.game.startingDate.getMonthValue()));
    CharacterUtils.addAttribute(doc,dateNode,"String_Node_Str",String.valueOf(Main.game.startingDate.getDayOfMonth()));
    CharacterUtils.addAttribute(doc,dateNode,"String_Node_Str",String.valueOf(Main.game.startingDate.getHour()));
    CharacterUtils.addAttribute(doc,dateNode,"String_Node_Str",String.valueOf(Main.game.startingDate.getMinute()));
    Main.game.dialogueFlags.saveAsXML(game,doc);
    Element eventLogNode=doc.createElement("String_Node_Str");
    game.appendChild(eventLogNode);
    for (    EventLogEntry event : Main.game.getEventLog()) {
      event.saveAsXML(eventLogNode,doc);
    }
    Element mapNode=doc.createElement("String_Node_Str");
    game.appendChild(mapNode);
    for (    World world : Main.game.getWorlds().values()) {
      if (world != null) {
        world.saveAsXML(mapNode,doc);
      }
    }
    Element characterNode=doc.createElement("String_Node_Str");
    game.appendChild(characterNode);
    Main.game.getPlayer().saveAsXML(characterNode,doc);
    for (    GameCharacter character : Main.game.getNPCMap().values()) {
      characterNode=doc.createElement("String_Node_Str");
      game.appendChild(characterNode);
      character.saveAsXML(characterNode,doc);
    }
    TransformerFactory tf=TransformerFactory.newInstance();
    Transformer transformer1=tf.newTransformer();
    transformer1.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
    StringWriter writer=new StringWriter();
    transformer1.transform(new DOMSource(doc),new StreamResult(writer));
    TransformerFactory transformerFactory=TransformerFactory.newInstance();
    Transformer transformer=transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
    transformer.setOutputProperty("String_Node_Str","String_Node_Str");
    DOMSource source=new DOMSource(doc);
    File dir=new File("String_Node_Str");
    dir.mkdir();
    File dirCharacter=new File("String_Node_Str");
    dirCharacter.mkdir();
    int saveNumber=0;
    String saveLocation="String_Node_Str" + Main.game.getPlayer().getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str";
    if (new File("String_Node_Str" + Main.game.getPlayer().getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str").exists()) {
      saveLocation="String_Node_Str" + Main.game.getPlayer().getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str"+ saveNumber+ "String_Node_Str";
    }
    while (new File("String_Node_Str" + Main.game.getPlayer().getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str"+ saveNumber+ "String_Node_Str").exists()) {
      saveNumber++;
      saveLocation="String_Node_Str" + Main.game.getPlayer().getName() + "String_Node_Str"+ Main.game.getDayNumber()+ "String_Node_Str"+ saveNumber+ "String_Node_Str";
    }
    StreamResult result=new StreamResult(new File(saveLocation));
    transformer.transform(source,result);
    if (timeLog) {
      System.out.println("String_Node_Str" + (System.nanoTime() - timeStart) / 1000000000f);
    }
  }
 catch (  ParserConfigurationException pce) {
    pce.printStackTrace();
  }
catch (  TransformerException tfe) {
    tfe.printStackTrace();
  }
}

Fixed version (ground truth):
public static void exportGame(String exportFileName,boolean allowOverwrite){
  File dir=new File("String_Node_Str");
  dir.mkdir();
  dir=new File("String_Node_Str");
  dir.mkdir();
  boolean overwrite=false;
  if (dir.isDirectory()) {
    File[] directoryListing=dir.listFiles((path,filename) -> filename.endsWith("String_Node_Str"));
    if (directoryListing != null) {
      for (      File child : directoryListing) {
        if (child.getName().equals(exportFileName + "String_Node_Str")) {
          if (!allowOverwrite) {
            Main.game.flashMessage(Colour.GENERIC_BAD,"String_Node_Str");
            return;
          }
 else {
            overwrite=true;
          }
        }
      }
    }
  }
  try {
    if (timeLog) {
      timeStart=System.nanoTime();
      System.out.println(timeStart);
    }
    DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder=docFactory.newDocumentBuilder();
    Document doc=docBuilder.newDocument();
    Element game=doc.createElement("String_Node_Str");
    doc.appendChild(game);
    Element informationNode=doc.createElement("String_Node_Str");
    game.appendChild(informationNode);
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",Main.VERSION_NUMBER);
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",String.valueOf(Main.game.minutesPassed));
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",String.valueOf(Main.game.debugMode));
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",String.valueOf(Main.game.imperialMeasurements));
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",Main.game.currentWeather.toString());
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",String.valueOf(Main.game.nextStormTime));
    CharacterUtils.addAttribute(doc,informationNode,"String_Node_Str",String.valueOf(Main.game.weatherTimeRemaining));
    Element dateNode=doc.createElement("String_Node_Str");
    informationNode.appendChild(dateNode);
    CharacterUtils.addAttribute(doc,dateNode,"String_Node_Str",String.valueOf(Main.game.startingDate.getYear()));
    CharacterUtils.addAttribute(doc,dateNode,"String_Node_Str",String.valueOf(Main.game.startingDate.getMonthValue()));
    CharacterUtils.addAttribute(doc,dateNode,"String_Node_Str",String.valueOf(Main.game.startingDate.getDayOfMonth()));
    CharacterUtils.addAttribute(doc,dateNode,"String_Node_Str",String.valueOf(Main.game.startingDate.getHour()));
    CharacterUtils.addAttribute(doc,dateNode,"String_Node_Str",String.valueOf(Main.game.startingDate.getMinute()));
    Main.game.dialogueFlags.saveAsXML(game,doc);
    Element eventLogNode=doc.createElement("String_Node_Str");
    game.appendChild(eventLogNode);
    for (    EventLogEntry event : Main.game.getEventLog()) {
      event.saveAsXML(eventLogNode,doc);
    }
    Element mapNode=doc.createElement("String_Node_Str");
    game.appendChild(mapNode);
    for (    World world : Main.game.getWorlds().values()) {
      if (world != null) {
        world.saveAsXML(mapNode,doc);
      }
    }
    Element characterNode=doc.createElement("String_Node_Str");
    game.appendChild(characterNode);
    Main.game.getPlayer().saveAsXML(characterNode,doc);
    for (    GameCharacter character : Main.game.getNPCMap().values()) {
      characterNode=doc.createElement("String_Node_Str");
      game.appendChild(characterNode);
      character.saveAsXML(characterNode,doc);
    }
    TransformerFactory tf=TransformerFactory.newInstance();
    Transformer transformer1=tf.newTransformer();
    transformer1.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
    StringWriter writer=new StringWriter();
    transformer1.transform(new DOMSource(doc),new StreamResult(writer));
    TransformerFactory transformerFactory=TransformerFactory.newInstance();
    Transformer transformer=transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
    transformer.setOutputProperty("String_Node_Str","String_Node_Str");
    DOMSource source=new DOMSource(doc);
    String saveLocation="String_Node_Str" + exportFileName + "String_Node_Str";
    StreamResult result=new StreamResult(new File(saveLocation));
    transformer.transform(source,result);
    if (overwrite) {
      if (!exportFileName.startsWith("String_Node_Str")) {
        Main.game.setContent(new Response("String_Node_Str","String_Node_Str",Main.game.getCurrentDialogueNode()),Colour.GENERIC_GOOD,"String_Node_Str");
      }
    }
 else {
      Main.game.setContent(new Response("String_Node_Str","String_Node_Str",Main.game.getCurrentDialogueNode()),Colour.GENERIC_GOOD,"String_Node_Str");
    }
    if (timeLog) {
      System.out.println("String_Node_Str" + (System.nanoTime() - timeStart) / 1000000000f);
    }
  }
 catch (  ParserConfigurationException pce) {
    pce.printStackTrace();
  }
catch (  TransformerException tfe) {
    tfe.printStackTrace();
  }
}