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

**URL:** <https://discourse.processing.org/t/reading-and-writing-variable-or-arrays-in-text-format-for-later-use/15561>\
**Category:** Coding Questions\
**Created:** [November 17, 2019, 4:15am UTC](https://discourse.processing.org/t/reading-and-writing-variable-or-arrays-in-text-format-for-later-use/15561 "2019-11-17T04:15:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [November 17, 2019, 4:15am UTC](https://discourse.processing.org/t/reading-and-writing-variable-or-arrays-in-text-format-for-later-use/15561/1 "2019-11-17T04:15:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 17, 2019, 4:16am UTC](https://discourse.processing.org/t/reading-and-writing-variable-or-arrays-in-text-format-for-later-use/15561/2 "2019-11-17T04:16:16Z")

</div>

saveStrings and loadStrings

Or saveTable and loadTable

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [November 17, 2019, 4:22am UTC](https://discourse.processing.org/t/reading-and-writing-variable-or-arrays-in-text-format-for-later-use/15561/3 "2019-11-17T04:22:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 17, 2019, 4:23am UTC](https://discourse.processing.org/t/reading-and-writing-variable-or-arrays-in-text-format-for-later-use/15561/4 "2019-11-17T04:23:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [November 17, 2019, 4:27am UTC](https://discourse.processing.org/t/reading-and-writing-variable-or-arrays-in-text-format-for-later-use/15561/5 "2019-11-17T04:27:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 17, 2019, 4:35am UTC](https://discourse.processing.org/t/reading-and-writing-variable-or-arrays-in-text-format-for-later-use/15561/6 "2019-11-17T04:35:52Z")

</div>

I don’t know

It’s fast enough

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [November 17, 2019, 6:30pm UTC](https://discourse.processing.org/t/reading-and-writing-variable-or-arrays-in-text-format-for-later-use/15561/7 "2019-11-17T18:30:26Z")

</div>

> [@paulgoux](#):
>
> Does this require extra libraries or is it pre-included?

See the [reference page](https://processing.org/reference/)

- [saveStrings() / Reference / Processing.org](https://processing.org/reference/saveStrings_.html)
- [saveTable() / Reference / Processing.org](https://processing.org/reference/saveTable_.html)

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [November 17, 2019, 6:43pm UTC](https://discourse.processing.org/t/reading-and-writing-variable-or-arrays-in-text-format-for-later-use/15561/8 "2019-11-17T18:43:02Z")

</div>

> [@paulgoux](#):
>
> is the Java native BufferedWriter an improvement over this method in any way in terms of speed

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-](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#saveStrings-java.io.File-java.lang.String:A-)

In the source:

> <https://github.com/processing/processing/blob/63e41a8a99566f345fe8343fce3071c9874135e7/core/src/processing/core/PApplet.java#L7938-L7945>

While saveTable opens a File and then passes from PApplet:

> <https://github.com/processing/processing/blob/63e41a8a99566f345fe8343fce3071c9874135e7/core/src/processing/core/PApplet.java#L6295-L6304>

to the Table object save method:

> <https://github.com/processing/processing/blob/63e41a8a99566f345fe8343fce3071c9874135e7/core/src/processing/data/Table.java#L1180-L1226>
