We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I run this piece of code inside a bigger loop, these lines save a string in a .txt file called "kinectDEM.tmp", before to do that the old file is renamed in "kinectDEM1.txt" and the new one ("kinectDEM.tmp") is renamed in"kinectDEM0.txt". It works fine but sometimes it get stuck and the "kinectDEM1.txt" disappear, blocking the loop. How can I fix it?
if (millis() > precedente + savingtimestep) {
txt[0] = "ncols 600\nnrows 480\nxllcorner 0\nyllcorner 0\ncellsize 1\nNODATA_value 10\n" +kinectDEM;
saveStrings("kinectDEM0.tmp", txt);
precedente = millis();
// delete the old .txt file, from kinectDEM1 to kinectDEMtrash
File f = new File(sketchPath("kinectDEM1.txt"));
boolean success = f.delete();
// rename the old .txt file, from kinectDEM0 to kinectDEM1
File oldName1 = new File(sketchPath("kinectDEM0.txt"));
File newName1 = new File(sketchPath("kinectDEM1.txt"));
oldName1.renameTo(newName1);
// rename kinectDEM0.tmp file to kinectDEM0.txt
File oldName2 = new File(sketchPath("kinectDEM0.tmp"));
File newName2 = new File(sketchPath("kinectDEM0.txt"));
oldName2.renameTo(newName2);
}
Answers
https://forum.Processing.org/two/discussion/16001/add-0-s-to-date-time-in-the-filename-with-saveframe#Item_3
Thanks #GoToLoop but I didn't get the hint. Should I use
final
?Oh, just thought using timestamps would be much less of a hassle & safer than delete() & renameTo() all the time. 8-X
I don't know timestamp...
https://en.Wikipedia.org/wiki/Timestamp