Related thread in the forum: http://forum.processing.org/two/discussion/12218/why-can-t-i-read-a-json-file-with-a-different-program-while-my-sketch-is-still-open
Problematic code:
public boolean save(File file, String options) {
return write(PApplet.createWriter(file), options);
}
write() cannot close the writer itself (it owns to the caller) but in save(), it should manage the lifetime of the writer.
So I propose something like:
public boolean save(File file, String options) {
PrintWriter writer = PApplet.createWriter(file);
boolean r = write(writer, options);
writer.close();
return r;
}
Or, cleaner, wrap the call in a try ./ finally, as write() can throw an exception.
Related thread in the forum: http://forum.processing.org/two/discussion/12218/why-can-t-i-read-a-json-file-with-a-different-program-while-my-sketch-is-still-open
Problematic code:
write() cannot close the writer itself (it owns to the caller) but in save(), it should manage the lifetime of the writer.
So I propose something like:
Or, cleaner, wrap the call in a try ./ finally, as write() can throw an exception.