Reading and writing variable or arrays in text format for later use

As the title suggests, whats the best method for doing this?

saveStrings and loadStrings

Or saveTable and loadTable

2 Likes

Does this require extra libraries or is it pre-included?

That’s for writing on your hard drive

Do you mean this? Or just storing during you run the sketch?

It’s included. See reference

Saving to disk, thanks shall check it out, is the Java native BufferedWriter an improvement over this method in any way in terms of speed, or are they pretty comparable?

I don’t know

It’s fast enough

See the reference page

When in doubt, test, as differences in performance if any may depend a lot on your use case (e.g. many small files vs. one huge file, etc.). saveTable has a lot of data processing overhead – although for most application that doesn’t matter, as these things are still quite fast – while saveStrings is close to native. You can also pass saveStrings an OutputStream if you wish.

In the JavaDoc:

http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#saveStrings-java.io.File-java.lang.String:A-

In the source:

While saveTable opens a File and then passes from PApplet:

to the Table object save method:

2 Likes