I have a simple xml file, which I update every 3 seconds (by completely replacing contents each time)
I have a problem when computer restarts for any reason (or I long-press the power button to shut it down) - the xml file ends up filled with zero-characters. Same length as proper data, but 0's instead.
I tried saving to tmp file first, validating the data and replacing the original xml file if data seems valid. Did not help. Looks like all validation works fine (SAXBuilder doesnt throw exceptions, I can locate proper child notes etc.), but the file is still corrupted in the end.
I use XMLOutputter and FileWriter to save the data to the temp file. Then replace original with couple renameTo()'s
All works well if I just exit the application or kill the process from task manager. Just the restart/shutdown breaks things.
Any hints on why this is happening will be greatly appreciated.