We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Saving to text file
Page Index Toggle Pages: 1
Saving to text file (Read 1131 times)
Saving to text file
Apr 23rd, 2007, 3:49pm
 
I have been having problems saving variables to a text document, so I was wondering if anyone could give an example of code for saving a string variable to a text document.
Re: Saving to text file
Reply #1 - Apr 23rd, 2007, 7:09pm
 
saveStrings() has all you need ..

F
Re: Saving to text file
Reply #2 - Apr 27th, 2007, 5:50pm
 
for:

saveStrings("file.txt", me);

i get:

No applicable overload for a method with signature "saveStrings(java.lang.String, java.lang.String)" was found in type "processing.core.PApplet".

Perhaps you wanted the overloaded version "void saveStrings(java.io.OutputStream $1, java.lang.String[] $2);" instead?

what am i doing wrong?
Re: Saving to text file
Reply #3 - Apr 27th, 2007, 6:47pm
 
You have to save an array of strings, not a single one.

So you need:

Code:
String[] output=new String[0];
output=append(output,me);
saveStrings("file.txt",output);

Re: Saving to text file
Reply #4 - Apr 27th, 2007, 10:20pm
 
or use the PrintWriter example:
http://processing.org/reference/PrintWriter.html
if you want to write multiple lines without first shoving them into an array.
Page Index Toggle Pages: 1