We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am creating a program that uses an Xbox Kinect to manipulate a 3D object, and I have a lot of information outputting to the Processing Console. Some of this information I can control, such as my threshold and zoom variables, but some of it I can't, like errors thrown by the Kinect library and such.
I have searched the forums and Google to find a way to grab the console output, but I have only been able to find discussions about logging the output to a file. What I am trying to do is mimic the Processing Console in my final program by keeping a buffer of the last X output messages (from both
System.err.out()) and show them to the user on request.
Like I said, I know I could wrap my print statements in something that both stores them and outputs them to the debugging console, but I can't do that for external libraries and other runtime exceptions. I am looking for a general way to intercept the standard output and store it in an array (or two, one for errors and one for messages).
Any help is appreciated, thanks in advance.
Look up three things-
So all you have to do is create your own OutputStream, use it to create a PrintStream and set the System's out and err to that PrintStream. Since your OutputStream will have its own custom write(byte b) method, use it to store all the bytes to a new Array, then it can be converted into a String too.
P.S. The write method actually accepts an int, but since only the 8 low-order bits are written, I mentioned is as byte.