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 › save contents of console to a file
Page Index Toggle Pages: 1
save contents of console to a file (Read 559 times)
save contents of console to a file
Feb 7th, 2006, 1:04pm
 
Hi there,

just wondering if anyone knows of a way to copy the contents of the console window and save it to a text file.  I know that processing automatically saves the contents to a file somewhere- my problem is that I need to save the console window contents to a unique file each time I run my processing code.  

Thanks for your help, Andy.
Re: save contents of console to a file
Reply #1 - May 3rd, 2006, 6:45pm
 
There are better ways to do this, I'm sure, but this bit of code will do what you want. it redirects all print and println statements to the specified path and filename.

import java.io.*;

PrintStream      ps;             // used to redirect the standard output (global variable)

 //re-direct standard output to a logfile
void redirectStdOut(String filename) throws IOException {
   FileOutputStream fos =
     new FileOutputStream(filename,true);
   BufferedOutputStream bos =
     new BufferedOutputStream(fos, 1024);
   ps =
     new PrintStream(bos, false);

   System.setOut(ps);
 }

Hope this helps!

Quote:
I know that processing automatically saves the contents [of the console window] to a file somewhere

This sounds nifty!  Can anyone verify this?  Where is this file located?
Re: save contents of console to a file
Reply #2 - May 3rd, 2006, 8:31pm
 
look for "stdout.txt" on your system as defined in "lib/preferences.txt" (next to processing-app). but i'm not sure where to and when it's written.


F
Page Index Toggle Pages: 1